[Bug other/55981] New: std::atomic store is split in two smaller stores

eugeni.stepanov at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jan 14 22:39:00 GMT 2013


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

             Bug #: 55981
           Summary: std::atomic store is split in two smaller stores
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: eugeni.stepanov@gmail.com


Created attachment 29166
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29166
miscompiled program

Hi,

in the attached program, std::atomic<unsigned long> store is compiled as two
4-byte stores, becoming not atomic at all. This happens at -O2 and higher.

To reproduce,
# g++ -std=c++11 -O3 1.cc  -lpthread -o 1
# ./1
100000004

^ this can also be 300000002, both outcomes are invalid.



More information about the Gcc-bugs mailing list