🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1059

#define multi-lined strings

#1059
From: Pierre Willard
Date: Thu, 03 Sep 1992 19:06
89 lines
2590 bytes
There is a bug in the preprocessor of gcc 2.1 and 
gcc-1.40.

It is possible to write a #define which will generate several C lines
in the preprocessed file. This makes bad line numbers. This happens
when using a multi-lined string in a #define.

I guess the fix is for cpp to translate a mutli-lined string in a
#define into a one line string (ie use '\n').

In the example below, cpp should output :

"just\na little\nmulti-lined\nstring"; foo(x)

The following demonstrates the problem.

psi:/usr2/pierre:cat pw.c

#define FOOO x = "just
a little
multi-lined
string"; foo(x)

void
foo(char *x)
{

}

main()
{
char *x;

  FOOO;
}
psi:/usr2/pierre:gcc -E pw.c
# 1 "pw.c"






void
foo(char *x)
{

}

main()
{
char *x;

  x = "just
a little
multi-lined
string"; foo(x) ;
# 18 "pw.c"
}
psi:/usr2/pierre:gcc -v -g -O -o pw pw.c
Reading specs from /usr/local/lib/gcc-lib/sun4/2.1/specs
gcc version 2.1
 /usr/local/lib/gcc-lib/sun4/2.1/cpp -lang-c -v -undef -D__GNUC__=2 -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -D__OPTIMIZE__ -g pw.c /usr/tmp/cca24573.i
GNU CPP version 2.1 (sparc)
 /usr/local/lib/gcc-lib/sun4/2.1/cc1 /usr/tmp/cca24573.i -quiet -dumpbase pw.c -g -O -version -o /usr/tmp/cca24573.s
GNU C version 2.1 (sparc) compiled by GNU C version 2.1.
 as -o pw.o /usr/tmp/cca24573.s
 /usr/local/lib/gcc-lib/sun4/2.1/ld -e start -dc -dp -o pw /lib/crt0.o -L/usr/local/lib/gcc-lib/sun4/2.1/ -L/usr/local/lib/ pw.o -lgcc -lc -lg -lgcc
psi:/usr2/pierre:gdb pw
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.5, Copyright 1992 Free Software Foundation, Inc...
(gdb) b main
Breakpoint 1 at 0x22cc: file pw.c, line 17.
(gdb) run
Starting program: /usr2/pierre/pw 

Breakpoint 1, main () at pw.c:17
17	  FOOO;
(gdb) n
Line number 20 out of range; pw.c has 18 lines.
(gdb) quit
The program is running.  Quit anyway? (y or n) y
psi:/usr2/pierre:

Let me know your comments.
Regards
Pierre Willard
Technical Details
Message-ID: <9209031906.AA17893@_la.tce.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!la.tce.COM!pierre

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!la.tce.COM!pierre
From: pierre@la.tce.COM (Pierre Willard)
Subject: #define multi-lined strings
Message-ID: <9209031906.AA17893@_la.tce.com>
Sender: gnulists@ai.mit.edu
Reply-To: pierre@la.tce.com
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 3 Sep 1992 19:06:08 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 91