id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 7892,boost.atomic misbehaves with Apple clang version 4.1 and -O2,Andreas Beisler ,timblechmann,"There seems to be an issue, when assigning to an atomic in a ""while (true)"" loop (without break statement!). {{{ #include void this_works() { boost::atomic_bool b(false); std::cout << b << std::endl; // 0 b = true; std::cout << b << std::endl; // 1 } void this_works_too() { boost::atomic_bool b(false); while (true) { std::cout << b << std::endl; // 0 b = true; std::cout << b << std::endl; // 1 break; } } void this_doesnt_work() { boost::atomic_bool b(false); while (true) { std::cout << b << std::endl; // 0 b = true; std::cout << b << std::endl; // 0 } } // Issue arises when compiled with Apple LLVM 4.1 and -O2: // clang++ -O2 main.cpp int main(int argc, char ** argv) { this_works(); this_works_too(); this_doesnt_work(); return 0; } }}} This happens only when the optimization level is set to at least 2. It happens in clang++ 4.1, but works in clang++ 3.2. Maybe it's possible to work around that issue, since std::atomic works fine. Best regards, Andreas ",Bugs,closed,To Be Determined,atomic,Boost Release Branch,Problem,wontfix,,