September 08, 2003
Hi,

Some time ago, I reported a bug while compiling Lua script language (5.0), but I couldn't isolate the problem on a smaller example.

Now, I have manage to separate it from Lua source.

The problem happens when compiling with optimizations (-o+all)

The while loop in foo function, loops exactly the same as the non optimize version, but in the optimized version the tl value isn't updated at loop exit, (I can't find tl value inside the loop, because any use of tl, (such as printf) makes the problem to disappear).

Note that the while condition doesn't have side effects and it's body only accumulates the lengths in tl and increment n.

There is also the case that if I remove the double n member of the
Value union the problem disappear.
This pattern repeats for the 64 bits types (double, long long int).

The compiler version is 8.35n

>dmc bug.c
>bug
**tl=10,n=4 (correct)

>dmc -o+all bug.c
>bug
**tl=4,n=4 (error)

Thanks.

Eduardo Nunes
edfpn 'at' hotmail 'dot' com




September 08, 2003
Thanks, I can take it from here. -Walter