On Sun, 2010-01-03 at 10:31 -0800, Patrick Horgan wrote: > 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?
Herb is C++ ... The C1x timetable has us finishing the draft for an initial ballot this summer (the April Florence meeting being the last chance to submit new material). The best expert I know on the type based aliasing stuff is Clark Nelson at Intel (clark.nel...@intel.com). We did spend a considerable amount of time at the recent Santa Cruz meeting discussing this subject ... see N1409 and N1422 (the minutes including a summary of the discussion on N1409). http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1409.htm http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1422.pdf > > > 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 -- Nick