|
|
Message-ID: <20140619033409.GK179@brightrain.aerifal.cx>
Date: Wed, 18 Jun 2014 23:34:09 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: broken gcc optimization for facilitynames
On Wed, Jun 18, 2014 at 04:31:58PM +0000, Clément Vasseur wrote:
> Hello,
>
> I might have found a gcc code generation problem with the facilitynames
> implementation used in musl. See the following reduced test case:
>
> $ cat test-facilitynames.c
> #define SYSLOG_NAMES
> #include <syslog.h>
> int main(void)
> {
> for (int i = 0; facilitynames[i].c_name; i++)
> if (facilitynames[i].c_name)
> return facilitynames[i].c_val;
> }
>
> $ musl-gcc -std=gnu99 -O1 test-facilitynames.c && ./a.out; echo $?
> 32
>
> $ musl-gcc -std=gnu99 -O2 test-facilitynames.c && ./a.out; echo $?
> 1
>
> I see similar results with gcc versions 4.6.1, 4.8.3 and 4.9.0 (with a
> different return value with -O2).
I can verify that I see this one on gcc 4.7.3. I don't see any UB in
the code so I'm pretty sure this is a gcc bug.
Note that we should really fix this horrible definition of
facilitynames (it bloats busybox by quite a bit), but it's a nice
demonstration of the gcc bug which we should also report and try to
get fixed..
Can you make a self-contained test case (copy the macros from musl's
syslog.h into the source file) and file a gcc bug report?
Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.