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: unassig...@gcc.gnu.org ReportedBy: eugeni.stepa...@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.