[Bug middle-end/122760] Missed optimization: constexpr std::atomic<int> x{0} not constant-propagated through load()
marc.mutz at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Nov 19 10:23:28 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122760
--- Comment #3 from Marc Mutz <marc.mutz at hotmail dot com> ---
One could argue that a memory barrier would need to remain when the seq_cst
implicit operator int() is called, even though the actual load of the variable
(and the variable itself) can be optimized out. But with load(relaxed), there
is no ordering, so there's no side-effect that would have to remain, so I don't
see what could stand in the way of the optimization.
More information about the Gcc-bugs
mailing list