GCC aliasing rules: more aggressive than C99?

Robert Dewar dewar@adacore.com
Wed Jan 6 16:22:00 GMT 2010


Erik Trulsson wrote:

> I think 6.2.5 clause 27 is very relevant for this. It says that 'pointer to
> int' and 'pointer to union' do not need to have the same representation as
> each other.  It also seems that 'pointer to int' and 'pointer to unsigned
> int' do not need to have the same representation requirements (at least I
> cannot find anything that says that signed and unsigned variants are
> compatible types.) (Which I must admit comes as a bit of a surprise to me.)
> 
> So, yes, that example does technically seem to be undefined (but I don't
> know of any real-world implementation where it would not work as expected.)

undefined = undefined

The notion of "work as expected" is a dangerous one, not to be
encouraged at all.



More information about the Gcc mailing list