This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/38486] Missing warning about type punning
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Dec 2008 10:11:32 -0000
- Subject: [Bug middle-end/38486] Missing warning about type punning
- References: <bug-38486-4938@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from rguenth at gcc dot gnu dot org 2008-12-12 10:11 -------
Yes. Though you have to be careful not to create false positives for
float f;
struct X { int i; };
struct X *p = (struct X *)&f;
float *q = (float *)&p->i;
return *q;
if the code is obfuscated enough that the definition of p is not visible.
Or, one could even say that creating VIEW_CONVERT_EXPR <float> (p->i) is
an invalid transformation and causes an alias violation. Do we do this
transformation in this case? I think we should avoid doing it here
(that is, whenever the expression we view-convert contains a pointer
dereference).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38486