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

--- Comment #5 from James Y Knight <foom at fuhm dot net> ---
(oops submitted commit by mistake, continuing...)

Strangely, it appears that Clang and GCC both have odd behaviors currently, but
somewhat opposites:

- GCC appears to evaluate weak constants _only_ in frontend constant
evaluation. It does not treat them as known during backend optimizations.
(However, GCC does not allow you to use such a variable in a context that is
required to be constant by language rules).

- Clang evaluates weak constants _only_ in backend optimizations, and never in
frontend constant evaluation.


Clang will be changing to stop optimizing based on weak constant value, so that
they are consistently treated as unknown values.

I'd suggest that GCC probably ought to do the same (by no longer constant
evaluating such variables).

Reply via email to