Clarification on Gcc's strict aliasing rules

Andrew Haley aph@redhat.com
Thu Nov 11 09:23:00 GMT 2010


On 11/10/2010 11:47 PM, Patrick Horgan wrote:
> On 11/10/2010 01:16 AM, Andrew Haley wrote:
>> ...elision by patrick...
>> The aliasing rules are nothing to do with C99: they have always
>> been in Standard C.

> Thanks.  I didn't know that (or if I did I forgot somewhere).  I just
> really noticed people talking about strict aliasing lately (the last 3
> or 4 years I've seen it a lot).  Do you think it's because the compilers
> are getting better at complaining about type-punning that's outside of
> the aliasing rules?

I suspect so.

>> You really ought to refer to the standard, so people can see the
>> official rules for themselves.

> That's a good point.  I suppose I could put a link to a publicly
> available draft version of the C and the C++ standards.  Is there
> anyplace now where a final (non-draft) version of some version of the C
> and the C++ standards if freely available to the public?

No chance!  The official versions cost money, the final drafts don't.
There's no difference in the text.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf

> I've seen though that often people go to the standards and look at the
> aliasing rules with a strange world view and get more confused about
> aliasing and not less.  That's really the point of my document, to get
> regular developers to understand what aliasing is before they go and
> look at the rules so they understand what they're reading.  Do you
> suppose it would be appropriate to refer them to the standards at the
> end of the top section, before I start the type-punning section?

I'd suggest proper references: every time you say something, point to
to the section in the standard by giving a paragraph number.

Andrew.



More information about the Gcc-help mailing list