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.

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.

FWIW printf calls in pop() or any other functions did not affect the
calculation. push() is being given the correct argument after strtod.

- Lauri

-- 
http://www.fastmail.fm - The way an email service should be

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to