This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug regression/40665] dereferencing type-punned pointer warnings cannot be disabled
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Jul 2009 10:25:36 -0000
- Subject: [Bug regression/40665] dereferencing type-punned pointer warnings cannot be disabled
- References: <bug-40665-1600@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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