Package: gcc Version: 4.9 Severity: important Tags: upstream,confirmed,sid,experimental
GCC 4.9 introduced a bug in optimization (present at all -O levels except -O0) in the presence of extern objects with weak definitions local to the translation unit. The following minimal testcase shows the problem: static int dummy = 0; extern int foo __attribute__((__weak__, __alias__("dummy"))); int bar() { if (foo) return 1; return 0; } This should produce a nontrivial bar which can conditionally return 0 or 1 depending on the contents of foo. Instead, on 4.9.0, it produces a function which always returns 0. GCC versions with this bug have been reported to produce a seriously broken libc.a/libc.so for musl libc (e.g. fflush(NULL) fails to flush stdout). Removing static above causes the symptom to go away, so presumably GCC is wrongly transferring knowledge that "dummy" is static onto "foo", and thereby assuming "foo" is not externally reachable/modifiable. IIRC clang/LLVM had the same bug a couple years back and fixed it; it looks like GCC has newly introduced it. This bug affects at least the debian package "musl" which does not build correctly. -- To UNSUBSCRIBE, email to debian-gcc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/CALONj1eKCEhiWChLWhW5jW2fHPBr41W+TWG=dfewys1-ci4...@mail.gmail.com