------- Comment #6 from manu at gcc dot gnu dot org  2009-07-07 10:25 -------
(In reply to comment #5)
> 
> Thus code is undefined you have an acess of a char array as a struct.  
> Yes you are only taking the address of an element but it is still  
> considered an acess by the standards.

I see that users repeatedly fall for this. Could we detect what type is
accessed as what and provide an informative note? Something like:

warning: dereferencing type-punned pointer might break strict-aliasing rules
note: accessing 'char *' as 'structure *' is undefined

Andrew, do you think this would be difficult to implement?


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40665

Reply via email to