Problem with debugging quoted backslash-newline in macro
Ian Lance Taylor
ian@airs.com
Thu Dec 3 19:24:00 GMT 1998
Between egcs 1.0.3 and egcs 1.1 a bug was introduced into the C
preprocessor which affects the generation of debugging information
when using a macro with a backslash-newline in a string.
Consider this test case:
==================================================
#define t() \
asm ("nop; \
nop")
int
main ()
{
int l1, l2;
l1 = __LINE__;
t ();
l2 = __LINE__;
}
==================================================
The egcs 1.03 preprocessor will generate this:
==================================================
# 1 "foo.c"
int
main ()
{
int l1, l2;
l1 = 10;
asm ("nop; nop") ;
l2 = 12;
}
==================================================
The egcs 1.1 preprocessor will generate this:
==================================================
# 1 "foo.c"
int
main ()
{
int l1, l2;
l1 = 10;
asm ("nop; \
nop") ;
l2 = 12;
}
==================================================
Note that the asm now takes up two lines in the preprocessor output.
The effect is that cc1 now sees two lines where it should only see
one. This causes cc1 to lose track of the lines, and causes it to
generate debugging information incorrectly.
If you are using stabs debugging information, you can see the bug by
running objdump --debugging on a .o file compiled without
optimization. Look carefully at the line numbers, and see how they go
from 10 to 11 to 13. As is shown by the translation of the __LINE__
macro, and as can be seen in the source file itself, the debugging
information for the last line should indicate line 12, not line 13.
I suspect the bug entered egcs during the merge from gcc 2.8.
However, I have not tried to track it down further.
This bug is still in the current egcs development sources.
Ian
More information about the Gcc-bugs
mailing list