[BusyBox] Where do I report a compiler bug?

Rob Landley rob at landley.net
Mon Oct 13 13:05:35 UTC 2003

On Monday 13 October 2003 04:11, Wolfgang Denk wrote:
> In message <200310130319.57281.rob at landley.net> you wrote:
> > Yup, it's a compiler bug.  Here's the test case.  gcc 3.2.2 out of Red
> > Hat 9 miscompiles this with -Os, but compiles it correctly without -Os.
> ...
> > 		/* Bug: this fails to move array */
> >
> > 		while(i) {
> > 			mtfSymbol[i] = mtfSymbol[--i];
> > 		}
> Are you sure this is a compiler bug? Or is it undefined behaviour?

Yes, I'm sure it's a compiler bug.

If it was undefined behavior, dest[i]=source[i++] wouldn't work.  If the 
second occurrence of i could be evaluated before the first, then the 
postincrement on the second would change the value of the first.  (Note, just 
as preincrement says we must change the value before using it, postincrement 
says the value is changed for everyone after us who uses it.)  And that's an 
extremely common idiom.  It's evaluated from left to right.  Lvalue or not 
doesn't change that.  (I'm a bit sleep deprived just now, but I remember 
reading this in the spec ten years ago when I was studying what it would take 
to implement my own C compiler...)

I'd also like to point out that the problem only occurs when an optimization 
flag is given, and that it works correctly when you don't say -Os.

> Best regards,
> Wolfgang Denk


More information about the busybox mailing list