That C parser bug
Charles M. Hannum
root@ihack.net
Thu Oct 29 22:17:00 GMT 1998
Here's an even simpler case that shows the bug:
#define savechar(n) ((n > 0) ? 'a' : '\0')
foo(char *bufp)
{
int x = 80;
return ((*(bufp++) = savechar(x)));
}
It gets compiled (again, with `-O') as:
_foo:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
movb (%eax),%dl
movsbl %dl,%eax
leave
ret
As you can see, it's actually returning bufp[0], and doesn't change
the value at all.
Anyway, I'll look into this some more.
More information about the Gcc-bugs
mailing list