This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: cpp generates wrong #line directives
- To: Bruno Haible <haible at ilog dot fr>
- Subject: Re: cpp generates wrong #line directives
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Fri, 1 Sep 2000 10:43:42 -0700
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <14767.58622.594440.921701@honolulu.ilog.fr>
On Fri, Sep 01, 2000 at 07:18:54PM +0200, Bruno Haible wrote:
> Hi,
>
> When there are #line directives in a source C files, the #line
> directives emitted by "gcc -E" from this source file can be very
> different from the given ones. As a consequence, functions below that
> point get very wrong debugging information, and gdb displays totally
> useless line numbers.
>
> The data for this testcase is in
> http://clisp.cons.org/~haible/bug-cpp-20000901.tar.gz
> or
> ftp://clisp.cons.org/pub/lisp/clisp/snapshots/bug-cpp-20000901.tar.gz
>
> $ gcc -v
> Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.2/specs
> gcc version 2.95.2 19991024 (release)
> $ gcc -E stream.c > stream.i
>
> First look at stream.c line 10136. It contains a "#line 9811" statement,
> such that the following "goto read_next_char;" should be remembered as
> line 9818.
>
> Now look at stream.i line 43508. It contains a "# 9851" statement,
> thus pretending that the following "goto read_next_char;" were in line
> 9852. This is off by 33 lines.
(I hope this is machine-generated code I'm looking at...)
If you look at stream.i you'll see that the last chunk of code before
the goto read_next_char is
if (ergebnis==0)
goto empty_buffer;
}
}}}}
which corresponds to the code on lines 10057-10062 of stream.c
goto empty_buffer; /* kein Zeichen verfügbar */
/* ergebnis=1 -> Zeichen verfügbar */
}
}}}}
#else
#if defined(UNIX_TERM_TERMIOS) || defined(UNIX_TERM_TERMIO)
and that #if finds its #else on line 10138 of stream.c, right after
the #line you expect to trigger.
#line 9811
}
#else
/* Man könnte hier fcntl(stdin_handle,F_SETFL,...|FASYNC) verwenden */
/* und auf Signal SIGIO warten. Allerdings funktioniert das auf so */
/* wenigen Systemen (siehe Emacs), dass es sich wohl nicht lohnt. */
#endif
#endif
goto read_next_char;
}}
So the #line is inside a failed conditional block and is therefore
ignored. Maybe you need to move it down after the double #endif
there?
zw