Richard Guenther wrote:
On Sun, Jan 3, 2010 at 6:46 AM, Joshua Haberman <jhaber...@gmail.com> wrote:
... elision by patrick of part of a quote of 6.5 Expressions #7...
 * an aggregate or union type that includes one of the aforementioned
   types among its members (including, recursively, a member of a
   subaggregate or contained union), or

Literally interpreting this sentence the way you do removes nearly all
advantages of type-based aliasing that you have when dealing with
disambiguating a pointer dereference vs. an object reference
and thus cannot be the desired interpretation (and thus we do not allow this).
Since it would be hard to read this any other way, it seems then you maintain that you found a bug in the standard, has it been brought up to the committee? The latest draft I see still has that wording. Doesn't seem to be on the radar for C1x. This same thing has bitten me, though I agree with your rationale about how it would be a bad idea, still strictly speaking, gcc is not standards compliant on this one point, and rather than change gcc, the defect in the standard could be changed. If you don't have anyone participating on the committee right now, you only have to convince some one who is, e.g. Nick Stoughton or P. J. Plauger or Herb Sutter, right?

It basically would force us to treat *ptr vs. Obj as *ptr vs. *(Obj *)ptr2.

...more elision
I have seen other articles that interpret the standard in this way.
See section "Casting through a union (2)" from this article, which
claims that casts of this sort are legal and that GCC's warnings
against them are false positives:
 
http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html

Yes, this article contains many mistakes but the author failed to listen.
This one thing is, you say, not a mistake of the author but a mistake in the standard, and it's unkind to characterize it like that <grin;>
...elided a bunch--patrick...
Correct.  GCC follows its own documentation here, not some random
websites and maybe not the strict reading of the standard.  There are
other corner-cases where it does so, namely with the union type rule
(which I fail to come up with a std reference at the moment).
I hope in all of these cases it's been brought up as an issue, defects in the standard won't get fixed if there are no squeaky wheels!

Patrick

Reply via email to