This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/38486] Missing warning about type punning



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]