dc hitting a compiler bug, or undefined behavior

Ralf Friedl Ralf.Friedl at online.de
Sun Mar 30 15:26:34 UTC 2014


Lauri Kasanen schrieb:
> On Sun, Mar 30, 2014, at 15:05, Ralf Friedl wrote:
>>> I'm seeing busybox dc acting funny when compiled with some versions of
>>> gcc. This is on busybox git. The x86 binary busybox_unstripped and
>>> config are attached.
>>>
>>> gcc 4.2.2 - ok
>>> gcc 4.7.2:
>>> nc 10 1 add p
>>> 2.738e+93
>>>
>>> So either bb is hitting a compiler bug, or undefined behavior somewhere
>>> with new gcc's more aggressive optimizations.
>> I have 4.7.2 on x86 and I get 11 as output. You could add debug output
>> to push and pop to see what happens.
> I think it's related to
> http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
> which hit the radeon driver as well
> http://lists.freedesktop.org/archives/dri-devel/2013-August/044122.html
>
> but changing the stack[1] to stack[0], stack[], or even stack[10] did
> not fix the issue.
If the change didn't fix it, then maybe it's not related to that.

> What's even worse is that adding any output to push(), even a puts("hi")
> that does not print the argument or any of the stack vars, fixes it. So
> something magic is going on inside the GCC optimization, I'm afraid this
> is above my pay grade.
Could you send the file miscutils/dc.o that is created with and without 
this puts("hi") in push()?


More information about the busybox mailing list