public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/108900] New: [libcpp] cpp gives wrong line number information
@ 2023-02-23  8:35 libin.dang at gmail dot com
  2023-02-25 14:50 ` [Bug preprocessor/108900] [libcpp] cpp gives wrong line number information with a file huge number of lines libin.dang at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: libin.dang at gmail dot com @ 2023-02-23  8:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108900

            Bug ID: 108900
           Summary: [libcpp] cpp gives wrong line number information
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: libin.dang at gmail dot com
  Target Milestone: ---

Created attachment 54514
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54514&action=edit
test case

Reproduce:

$ /home/wrsadmin/works/gcc/b0/gcc/cpp -B /home/wrsadmin/works/gcc/b0/gcc main.c
-o main.i

$ tail main.i
header3 begins
header3 begins
# 1 "header2.h" 1
# 327614 "header3.h" 2
header3 ends
# 4 "header1.h" 2
# 1 "header4.h" 1
# 5 "header1.h" 2
header1 ends
# 2 "main.c" 2

$ cat -n header3.h | tail
327606  header3 begins
327607  header3 begins
327608  header3 begins
327609  header3 begins
327610  header3 begins
327611  header3 begins
327612  header3 begins
327613  header3 begins
327614  #include "header2.h"
327615  header3 ends


The line number information for `header3 ends' is wrong.

BTW, this issue is very sensitive to the input files, for example, if we add
another line `header3 begins' above the `#include "header2.h"' in header3.h, we
will get the correct result:

$ cat -n header3.h | tail
327607  header3 begins
327608  header3 begins
327609  header3 begins
327610  header3 begins
327611  header3 begins
327612  header3 begins
327613  header3 begins
327614  header3 begins
327615  #include "header2.h"
327616  header3 ends

$ tail main.i
header3 begins
header3 begins
# 1 "header2.h" 1
# 327616 "header3.h" 2
header3 ends
# 4 "header1.h" 2
# 1 "header4.h" 1
# 5 "header1.h" 2
header1 ends
# 2 "main.c" 2

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-28 14:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-23  8:35 [Bug preprocessor/108900] New: [libcpp] cpp gives wrong line number information libin.dang at gmail dot com
2023-02-25 14:50 ` [Bug preprocessor/108900] [libcpp] cpp gives wrong line number information with a file huge number of lines libin.dang at gmail dot com
2023-05-04 10:19 ` libin.dang at gmail dot com
2023-12-28 14:10 ` libin.dang at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).