Bug 20907 - [4.0 Regression] long comments throw off line numbers
Summary: [4.0 Regression] long comments throw off line numbers
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Per Bothner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2005-04-08 19:12 UTC by Devang Patel
Modified: 2005-04-24 20:43 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.0
Known to fail: 4.0.0 4.1.0
Last reconfirmed: 2005-04-19 21:30:11


Attachments
Tentative patch. (719 bytes, patch)
2005-04-19 21:29 UTC, Per Bothner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devang Patel 2005-04-08 19:12:41 UTC
It seems that long comment blocks can throw off gcc's notion of the source line number. Here is a 
sample test case (also attached in case the line breaks get messed up pasting in):
/*
This is a really long comment. This is a really long comment. This is a really long comment. This is a 
really long comment. This is a really long comment. This is a really long comment. This is a really long 
comment. This is a really long comment. This is a really long comment. This is a really long comment. 
This is a really long comment. This is a really long comment. This is a really long comment. This is a 
really long comment. This is a really long comment. This is a really long comment.
 */
#warning test warning
#include <stdio.h>

int main(int argc, char *argv)
{
        printf("This is line %d\n", __LINE__);
}
Comment 1 Andrew Pinski 2005-04-08 20:30:31 UTC
Confirmed.
This has been broken since at least "gcc version 3.5.0 20040909 (experimental)".
Comment 2 Andrew Pinski 2005-04-08 20:34:39 UTC
This broke between 20040201 and 20040301.
Comment 3 Andrew Pinski 2005-04-08 20:36:49 UTC
There were quiet a number of cpp patches during that time.
Comment 4 Per Bothner 2005-04-19 21:29:43 UTC
Created attachment 8685 [details]
Tentative patch.
Comment 5 GCC Commits 2005-04-21 17:09:00 UTC
Subject: Bug 20907

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	bothner@gcc.gnu.org	2005-04-21 17:08:29

Modified files:
	libcpp         : line-map.c ChangeLog 

Log message:
	PR preprocessor/20907
	* line-map.c (linemap_line_start): Fix bug when we need to increse
	column_bits but can re-use the current line_map.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/line-map.c.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/ChangeLog.diff?cvsroot=gcc&r1=1.67&r2=1.68

Comment 6 Per Bothner 2005-04-21 17:21:51 UTC
Patch checked into mainline; not yet into 4.0 branch.
Comment 7 Devang Patel 2005-04-21 17:26:54 UTC
Subject: Re:  [4.0/4.1 Regression] long comments throw off line numbers

Would it be possible for you to add one test case also ?
Thanks,
-
Devang

Comment 8 GCC Commits 2005-04-21 18:40:24 UTC
Subject: Bug 20907

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	apple-local-200502-branch
Changes by:	dpatel@gcc.gnu.org	2005-04-21 18:40:08

Modified files:
	libcpp         : line-map.c ChangeLog.apple-ppc 
	gcc/testsuite  : ChangeLog.apple-ppc 
Added files:
	gcc/testsuite/gcc.apple: very-long-comment.c 

Log message:
	Radar 4058553
	Backport from FSF Mainline.
	2005-04-19  Per Bothner  <per@bothner.com>
	
	PR preprocessor/20907
	* line-map.c (linemap_line_start): Fix bug when we need to increse
	column_bits but can re-use the current line_map.
	
	* gcc.apple/very-long-comment.c: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/line-map.c.diff?cvsroot=gcc&only_with_tag=apple-local-200502-branch&r1=1.1&r2=1.1.52.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/ChangeLog.apple-ppc.diff?cvsroot=gcc&only_with_tag=apple-local-200502-branch&r1=1.1.4.4&r2=1.1.4.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.apple/very-long-comment.c.diff?cvsroot=gcc&only_with_tag=apple-local-200502-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.apple-ppc.diff?cvsroot=gcc&only_with_tag=apple-local-200502-branch&r1=1.1.4.22&r2=1.1.4.23

Comment 9 GCC Commits 2005-04-24 20:05:36 UTC
Subject: Bug 20907

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	bothner@gcc.gnu.org	2005-04-24 20:05:30

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/cpp: very-long-comment.c 

Log message:
	PR preprocessor/20907
	* gcc.dg/cpp/very-long-comment.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/cpp/very-long-comment.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5390&r2=1.5391

Comment 10 GCC Commits 2005-04-24 20:32:37 UTC
Subject: Bug 20907

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	bothner@gcc.gnu.org	2005-04-24 20:32:32

Modified files:
	libcpp         : line-map.c ChangeLog 

Log message:
	PR preprocessor/20907
	* line-map.c (linemap_line_start): Fix bug when we need to increse
	column_bits but can re-use the current line_map.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/line-map.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1&r2=1.1.54.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.56.2.5&r2=1.56.2.6

Comment 11 GCC Commits 2005-04-24 20:37:45 UTC
Subject: Bug 20907

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	bothner@gcc.gnu.org	2005-04-24 20:37:39

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/cpp: very-long-comment.c 

Log message:
	PR preprocessor/20907
	* gcc.dg/cpp/very-long-comment.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/cpp/very-long-comment.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.136&r2=1.5084.2.137

Comment 12 Andrew Pinski 2005-04-24 20:43:50 UTC
Fixed.