🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #731

1.36 cpp fails when stringifying (with patch)

#731
From: Tom Wood
Date: Thu, 19 Oct 1989 13:20
48 lines
1935 bytes
A problem occurs with the 1.36 preprocessor when stringifying.  Here's
the test case (minimal):

#ifdef __STDC__
#define Str(z)_Str(z)
#define _Str(z)#z
#else
#define Str(z)"z"
#endif

#define Indr

#define cast(t) *(t *)0

int pp_string()
{
  return Str(cast(int Indr));
}

What happens is that macroexpand of _Str is given the sequence 
"*(int \n  *)0\n )\n".  The erroneous output is "*(int  *)0" (two spaces).  
More importantly, this causes an internal abort in a larger case when the 
character count exceeds what was allocated.  Here's the fix:

*** cccp.c.orig	Wed Oct 18 16:34:05 1989
--- cccp.c	Wed Oct 18 15:52:20 1989
***************
*** 4244,4250 ****
  	    /* Internal sequences of whitespace are replaced by one space.  */
  	    if (c == '\n' ? arg->raw[i+1] == '\n' : is_space[c]) {
  	      while (1) {
! 		if (c == '\n' && arg->raw[i+1] == '\n')
  		  i += 2;
  		else if (c != '\n' && is_space[c])
  		  i++;
--- 4246,4253 ----
  	    /* Internal sequences of whitespace are replaced by one space.  */
  	    if (c == '\n' ? arg->raw[i+1] == '\n' : is_space[c]) {
  	      while (1) {
! 		/* The case this failed on is " \n  " (Newline Space occurs and should be ignored). */
! 		if (c == '\n' && is_space[arg->raw[i+1]])
  		  i += 2;
  		else if (c != '\n' && is_space[c])
  		  i++;
---
			Tom Wood	(919) 248-6067
			Data General, Research Triangle Park, NC
			{the known world}!rti!xyzzy!wood
Technical Details
Message-ID: <1974@xyzzy.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!xanth!mcnc!rti!xyzzy!dg-rtp.dg.com!wood

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!xanth!mcnc!rti!xyzzy!dg-rtp.dg.com!wood
From: wood@dg-rtp.dg.com (Tom Wood)
Newsgroups: gnu.gcc.bug
Subject: 1.36 cpp fails when stringifying (with patch)
Message-ID: <1974@xyzzy.UUCP>
Date: 19 Oct 89 13:20:27 GMT
Sender: usenet@xyzzy.UUCP
Reply-To: wood@dg-rtp.dg.com (Tom Wood)
Distribution: na
Organization: Data General Corporation, Research Triangle Park, NC
Lines: 47