home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / gcc / bug / 2253 < prev    next >
Encoding:
Text File  |  1992-09-03  |  2.4 KB  |  105 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!la.tce.COM!pierre
  3. From: pierre@la.tce.COM (Pierre Willard)
  4. Subject: #define multi-lined strings
  5. Message-ID: <9209031906.AA17893@_la.tce.com>
  6. Sender: gnulists@ai.mit.edu
  7. Reply-To: pierre@la.tce.com
  8. Organization: GNUs Not Usenet
  9. Distribution: gnu
  10. Date: Thu, 3 Sep 1992 19:06:08 GMT
  11. Approved: bug-gcc@prep.ai.mit.edu
  12. Lines: 91
  13.  
  14. There is a bug in the preprocessor of gcc 2.1 and 
  15. gcc-1.40.
  16.  
  17. It is possible to write a #define which will generate several C lines
  18. in the preprocessed file. This makes bad line numbers. This happens
  19. when using a multi-lined string in a #define.
  20.  
  21. I guess the fix is for cpp to translate a mutli-lined string in a
  22. #define into a one line string (ie use '\n').
  23.  
  24. In the example below, cpp should output :
  25.  
  26. "just\na little\nmulti-lined\nstring"; foo(x)
  27.  
  28. The following demonstrates the problem.
  29.  
  30. psi:/usr2/pierre:cat pw.c
  31.  
  32. #define FOOO x = "just
  33. a little
  34. multi-lined
  35. string"; foo(x)
  36.  
  37. void
  38. foo(char *x)
  39. {
  40.  
  41. }
  42.  
  43. main()
  44. {
  45. char *x;
  46.  
  47.   FOOO;
  48. }
  49. psi:/usr2/pierre:gcc -E pw.c
  50. # 1 "pw.c"
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. void
  58. foo(char *x)
  59. {
  60.  
  61. }
  62.  
  63. main()
  64. {
  65. char *x;
  66.  
  67.   x = "just
  68. a little
  69. multi-lined
  70. string"; foo(x) ;
  71. # 18 "pw.c"
  72. }
  73. psi:/usr2/pierre:gcc -v -g -O -o pw pw.c
  74. Reading specs from /usr/local/lib/gcc-lib/sun4/2.1/specs
  75. gcc version 2.1
  76.  /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
  77. GNU CPP version 2.1 (sparc)
  78.  /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
  79. GNU C version 2.1 (sparc) compiled by GNU C version 2.1.
  80.  as -o pw.o /usr/tmp/cca24573.s
  81.  /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
  82. psi:/usr2/pierre:gdb pw
  83. GDB is free software and you are welcome to distribute copies of it
  84.  under certain conditions; type "show copying" to see the conditions.
  85. There is absolutely no warranty for GDB; type "show warranty" for details.
  86. GDB 4.5, Copyright 1992 Free Software Foundation, Inc...
  87. (gdb) b main
  88. Breakpoint 1 at 0x22cc: file pw.c, line 17.
  89. (gdb) run
  90. Starting program: /usr2/pierre/pw 
  91.  
  92. Breakpoint 1, main () at pw.c:17
  93. 17      FOOO;
  94. (gdb) n
  95. Line number 20 out of range; pw.c has 18 lines.
  96. (gdb) quit
  97. The program is running.  Quit anyway? (y or n) y
  98. psi:/usr2/pierre:
  99.  
  100. Let me know your comments.
  101. Regards
  102. Pierre Willard
  103.  
  104.  
  105.