https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119666
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- The reporter thinks this is wrong-code. The C frontend rejects an extern const initialized object but handles the following not to the reporters expectations, optimizing it to return 4 (GCC 7 worked): const int __attribute__((weak)) x = 4; int foo() { return x; } I think a weak definition should only be replaceable with a semantically equivalent strong definition. Note I think we have testcases that verify we do not inline weak function definitions.