Hi, I think I am tracking a bug in egcs that appears not to
exist in gcc. Its a little beyond my abilities to solve, so
I am not sure how to ask for help.
I am compiling a routine that manipulates strings (actually, vsprintf,
from the linux kernel). It looks something like this:
void vsprintf (... char *ptr ... ) {
...
while (...) {
++ptr;
...
if ('%' == *ptr) ...
}
}
where ... == dozens of lines of code. The compiler appears to be
generating code that 'forgets' that the ptr was incremented back
when, and pulls an old, unincremented value out of the stack.
(Alternately, it forgot to write the new value back into the stack...)
I can make the bug go away by modifying as follows:
void vsprintf (... char *aaaptr ... ) {
char * ptr = aaaptr;
...}
and then everything works right ...
>From what I can tell, this bug occurs in egcs-1.1.1 and 1.1.2 but not gcc-2.8.1
(when compiled with -O2) (although I'm still checking). The back end is
the i370 back end which is identical for egcs and gcc. So I figure the back
end must not be at fault :-) And of course, linux vsprintf is known to work ...
so it would appear to be something funky that the optimizer is doing.
Anyone care to help me crack this?
--linas