Red Hat Bugzilla – Bug 448897
including <vector> generates aliasing error on double __attribute__ ((may_alias))
Last modified: 2008-05-29 11:05:39 EDT
Description of problem:
g++ -c -O2 -Werror=strict-aliasing -Wall may_alias.cxx
no errors, but
g++ -DINCLUDE_VECTOR -c -O2 -Werror=strict-aliasing -Wall may_alias.cxx
may_alias.cxx: In function ‘bool operator>>=(const Any&, long int&)’:
may_alias.cxx:30: error: dereferencing type-punned pointer will break
where INCLUDE_VECTOR just includes <vector>
strangely the effect is seen on the "double" but not on the "long" equivalent.
Created attachment 307043 [details]
Avoid may_alias type for now, apparently it never actually worked.
You can use unions, or asm optimization barriers, unions being preferred.
Yeah, but I got an alias from a void* to a class which has a constructor (!) and
that can't go into a union