Path: 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 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