Jens Gustedt's Blog

March 21, 2012

C11 defects: initialization of atomic_flag

Filed under: C11, defects, language — Jens Gustedt @ 16:44

With this post I will be starting some random collection of things that I consider being defects of the C11 standard. Perhaps someone of the committee could pick them up or send me a mail to discuss them and eventually formulate a formal defect report.

C11 expresses the intention to have atomic_flag as a primitive that should allow to emulate all other atomic types and operations, 7.17.8 p3 in a note says:

The remaining types can be emulated with atomic_flag, though with less than ideal properties.

(more…)

Advertisements

March 12, 2012

C data model, simplified view

Filed under: C11, C99, language — Jens Gustedt @ 23:55

As we have seen in the earlier post, if you dig deeper into it the C data model is quite complex and has corner cases that are a bit bizarre. This might make C weirder than it need to be at a first approach.

As I said, the two most important properties of objects (or values) in C are if they are mutable (or not) and if they are addressable (or not), leaving us with 4 principal categories of objects that we have to deal with.

(more…)

March 2, 2012

the C data model

Filed under: C11, C99, language, syntax — Jens Gustedt @ 02:52

For beginners in C the different terms that C applies to data items are often confusing. There are variables, literals, integer constants, compound literals, expressions, lvalues, rvalues… In this post I will try to put a bit of systematic into this and at the end move towards a simplified model.

First of all any sort of data in C usually has a type and a value. For example the literal 0 has the type signed int, 0u is unsigned int and 0.0 is double. But other kind of data may have different properties, e.g variables may be modifiable and may be scoped, some data has an address in memory and some doesn’t, etc.

(more…)

Create a free website or blog at WordPress.com.