[gccgo] Reinit varasm if unsafe is imported

Ian Lance Taylor iant@google.com
Sat Aug 28 07:36:00 GMT 2010


Normally for Go we can set flag_strict_aliasing.  However, if the unsafe
package is imported, Go permits pointers to be cast from one type to
another, so we must act as though -fno-strict-aliasing is set.  This can
only be determined after the compilation.

This mostly works fine, but unfortunately init_varasm_once is called
before the compilation, and it calls get_alias_set.  Since at that point
flag_strict_aliasing will normally be set, get_alias_set will return a
non-zero value.  If we later reset flag_strict_aliasing because unsafe
is imported, we will then trip an assert in
mems_in_disjoint_alias_sets_p in alias.c, which says that if
flag_strict_aliasing is false all alias sets should be zero.

This patch gets around this collision of expectations by re-initing
varasm when flag_strict_aliasing is clear.  This is hardly ideal, but it
will do for now.  Committed to gccgo branch.

Ian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-diff
Size: 1353 bytes
Desc: aliasing
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100828/dd77ab92/attachment.bin>


More information about the Gcc-patches mailing list