https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635

--- Comment #17 from Martin Sebor <msebor at gcc dot gnu.org> ---
The only way to avoid the warning in C (or std::optional) that I can think of
is to somehow obscure the access to the boolean flag.  Using volatile works but
looks like it has a cost that users wouldn't be happy about.  Using a relaxed
__atomic_store/_load also works and the optimized code doesn't look as bad, at
least not for the test case.  Obviously, neither is pretty but might be worth
looking into some more as a workaround.

Reply via email to