[Bug c/63645] Incorrect code generation

joseph at codesourcery dot com gcc-bugzilla@gcc.gnu.org
Mon Oct 27 15:43:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63645

--- Comment #19 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
Given

  GnmExprBinary res;
  GnmExpr const *expr = (GnmExpr *)&res;

the C standard does not define where the result of the conversion points; 
all that's defined is that if converted directly back to GnmExprBinary * 
(not via some sequence of intermediate types) it compares equal to the 
original pointer, if the original pointer was sufficiently aligned for 
GnmExpr * (and it is likely the latter type has stricter alignment 
requirements than GnmExprBinary *).

The effect is that the pointer resulting from the conversion cannot be 
dereferenced, only compared and converted back.

It is these limits on what pointer conversions are defined, together with 
the direct rules on what types of lvalues may access an object, that 
restrict aliasing in C.



More information about the Gcc-bugs mailing list