Today's CVS preprocessor ICE.
Zack Weinberg
zack@wolery.cumb.org
Fri May 19 09:31:00 GMT 2000
On Fri, May 19, 2000 at 11:18:15AM +0200, Mathias Froehlich wrote:
>
> Hi GCC Team,
>
> I have the today's (19.5.2000) CVS snapshot of gcc installed.
> Usung this Compiler I have got an ICE in the preprocessor compiling
> this short file:
>
> ---------------------------------------------------------
> #define foo
>
> #define __CAT__(a,b,c,d) a##b##c##d
> #define CAT(a,b,c,d) __CAT__(a,b,c,d)
>
> #define bar CAT(,foo,bar,)
> bar
> ---------------------------------------------------------
This bug has been there since forever. I am testing the appended
patch. With it applied I get simply
bar
as the preprocessed version of the file. Is that what you expected?
zw
* cpphash.c (funlike_macroexpand): Make sure not to walk p1
past l1 when deleting whitespace and markers.
===================================================================
Index: cpphash.c
--- cpphash.c 2000/05/18 15:55:45 1.90
+++ cpphash.c 2000/05/19 16:29:06
@@ -1578,7 +1578,7 @@ funlike_macroexpand (pfile, hp, args)
{
/* Arg is concatenated before: delete leading whitespace,
whitespace markers, and no-reexpansion markers. */
- while (p1 != l1)
+ while (p1 < l1)
{
if (is_space(p1[0]))
p1++;
@@ -1592,7 +1592,7 @@ funlike_macroexpand (pfile, hp, args)
{
/* Arg is concatenated after: delete trailing whitespace,
whitespace markers, and no-reexpansion markers. */
- while (p1 != l1)
+ while (p1 < l1)
{
if (is_space(l1[-1]))
l1--;
@@ -1612,7 +1612,7 @@ funlike_macroexpand (pfile, hp, args)
/* Delete any no-reexpansion marker that precedes
an identifier at the beginning of the argument. */
- if (p1[0] == '\r' && p1[1] == '-')
+ if (p1 + 2 <= l1 && p1[0] == '\r' && p1[1] == '-')
p1 += 2;
memcpy (xbuf + totlen, p1, l1 - p1);
More information about the Gcc-bugs
mailing list