Bug 448897 - including <vector> generates aliasing error on double __attribute__ ((may_alias))
including <vector> generates aliasing error on double __attribute__ ((may_ali...
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
All Linux
low Severity low
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-05-29 08:35 EDT by Caolan McNamara
Modified: 2008-05-29 11:05 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-05-29 10:16:06 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
example (892 bytes, text/plain)
2008-05-29 08:35 EDT, Caolan McNamara
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
GNU Compiler Collection 36369 None None None Never

  None (edit)
Description Caolan McNamara 2008-05-29 08:35:31 EDT
Description of problem:
gcc-4.3.0-8.i386

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
strict-aliasing rules
where INCLUDE_VECTOR just includes <vector>

strangely the effect is seen on the "double" but not on the "long" equivalent.
Demo attached
Comment 1 Caolan McNamara 2008-05-29 08:35:31 EDT
Created attachment 307043 [details]
example
Comment 2 Jakub Jelinek 2008-05-29 10:16:06 EDT
Avoid may_alias type for now, apparently it never actually worked.
You can use unions, or asm optimization barriers, unions being preferred.
Comment 3 Caolan McNamara 2008-05-29 11:05:39 EDT
Yeah, but I got an alias from a void* to a class which has a constructor (!) and
that can't go into a union

Note You need to log in before you can comment on or make changes to this bug.