[Bug middle-end/59448] Code generation doesn't respect C11 address-dependency

algrant at acm dot org gcc-bugzilla@gcc.gnu.org
Mon Jan 20 10:13:00 GMT 2014


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

--- Comment #8 from algrant at acm dot org ---
I don't see how f can not be 0 or 1 here, but to make this even more clear
that there is no UB, define flag this way:

  static std::atomic<unsigned int> flag(0);

and calculate the address this way:

      d = *(&data + (f - f));                                 // B.B

The ordering requirements are the same, and there is no possibility of UB.



More information about the Gcc-bugs mailing list