public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/61144] New: Invalid optimizations for extern vars with local weak definitions
@ 2014-05-11  1:30 bugdal at aerifal dot cx
  2014-05-11  3:20 ` [Bug c/61144] " pinskia at gcc dot gnu.org
                   ` (31 more replies)
  0 siblings, 32 replies; 33+ messages in thread
From: bugdal at aerifal dot cx @ 2014-05-11  1:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61144

            Bug ID: 61144
           Summary: Invalid optimizations for extern vars with local weak
                    definitions
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugdal at aerifal dot cx

GCC 4.8.2 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 bug is also present in 4.9.0. 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 gcc 4.8.2 and 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.

I don't know what component this should be marked as; sadly there's no
"unknown" option so I just put "c". It should presumably be on one of the
optimization ones, but I'm not sure which.


^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2014-10-05  4:58 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-11  1:30 [Bug c/61144] New: Invalid optimizations for extern vars with local weak definitions bugdal at aerifal dot cx
2014-05-11  3:20 ` [Bug c/61144] " pinskia at gcc dot gnu.org
2014-05-11  3:32 ` bugdal at aerifal dot cx
2014-05-11  3:33 ` bugdal at aerifal dot cx
2014-05-11 19:05 ` bugdal at aerifal dot cx
2014-05-11 19:41 ` pinskia at gcc dot gnu.org
2014-05-11 20:05 ` bugdal at aerifal dot cx
2014-05-12  4:18 ` cloos at jhcloos dot com
2014-05-12 13:23 ` jody at jodybruchon dot com
2014-05-12 13:59 ` cloos at jhcloos dot com
2014-05-12 17:42 ` bugdal at aerifal dot cx
2014-05-12 19:02 ` bugdal at aerifal dot cx
2014-05-12 20:31 ` glisse at gcc dot gnu.org
2014-05-13  3:26 ` bugdal at aerifal dot cx
2014-05-13  8:45 ` glisse at gcc dot gnu.org
2014-05-13 11:19 ` [Bug ipa/61144] [4.9/4.10 Regression] " rguenth at gcc dot gnu.org
2014-05-14  5:08 ` bugdal at aerifal dot cx
2014-05-20  8:31 ` bugdal at aerifal dot cx
2014-05-20 20:28 ` bugdal at aerifal dot cx
2014-06-26 13:05 ` rguenth at gcc dot gnu.org
2014-06-26 13:36 ` bugdal at aerifal dot cx
2014-07-02 12:23 ` patrick at parcs dot ath.cx
2014-07-02 14:47 ` bugdal at aerifal dot cx
2014-07-14 16:12 ` amonakov at gcc dot gnu.org
2014-07-14 16:13 ` amonakov at gcc dot gnu.org
2014-07-16 13:30 ` jakub at gcc dot gnu.org
2014-07-16 18:17 ` bugdal at aerifal dot cx
2014-07-30  9:14 ` hubicka at gcc dot gnu.org
2014-07-31 22:56 ` bugdal at aerifal dot cx
2014-10-05  4:56 ` [Bug ipa/61144] [4.9/5 " hubicka at gcc dot gnu.org
2014-10-05  4:56 ` hubicka at gcc dot gnu.org
2014-10-05  4:56 ` hubicka at gcc dot gnu.org
2014-10-05  4:58 ` hubicka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).