[Bug middle-end/39460] strange aliasing warnings compiling pymol under gcc 4.4

rguenth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Mar 14 09:32:00 GMT 2009



------- Comment #6 from rguenth at gcc dot gnu dot org  2009-03-14 09:32 -------
You can work around it in a gcc specific way by doing

typedef int my_aliased_int __attribute__((may_alias));

and using

  my_aliased_int *data = (int *) v;
  my_aliased_int *N;

This forces TBAA not to be applied to references through data and N.  Otherwise
it is hard to do without knowing the original object types (basically you would
need to make sure to do the memory accesses using the original type).

Or you can do all the memory accesses via memcpy like

  memcpy (&t0, &N[0], 4);

(which the compiler will optimize to the may_alias variant).  That would be
even portable to non-GCC compilers.

Richard.


-- 


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



More information about the Gcc-bugs mailing list