strict aliasing rules in ISO C, someone understands them ?

N

Netocrat

Netocrat said:
(e-mail address removed) wrote: [...]
It is not explicitly mentioned in the standard, but if access is
done through a struct, its type must match the type of the container of
the object we want to access.
It is mentioned at the member access operators. If it weren't, nobody
whould argure this.
[...]
I see no
mention of it in N869's "6.5.2.3 Structure and union members" which is the
section to which I presume you're referring.
My bad, sorry. It's not explicitly mentioned, but can be derived.
Pp. 3 and 4 refer to a "member of a structure or union object"; it means
the operator (and behaviour) is defined iff the _object_ has the specified
member.

OK - I was expecting something more explicit - the "iff" is implied - but
this seems to be a correct interpretation of the document's intent.
(However, I decline to explain what exactly it should be; I
think the Std means the effective type of the object; it's one of the
questions on my list to c.s.c.)

What else would it be? [*]
Anyway, if the Std text is not enough, then at least Example 3 shows the
intention; if it were allowed (in the example) to access `t1::m' with
`p2->m' (or vv.), then the second part of the example would be moot, as
well as the "special guarantee" of p. 5 would.

Sure - that makes the intent plain, even if the prior wording is not.

[*] My reaction to your comment in another thread - that you have your own
idea of what it means to "complete a type" - was similar: how many
alternative interpretations could there be?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top