This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Today's CVS preprocessor ICE.
- To: Mathias Froehlich <frohlich at na dot uni-tuebingen dot de>
- Subject: Re: Today's CVS preprocessor ICE.
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Fri, 19 May 2000 09:30:20 -0700
- Cc: gcc-bugs at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- References: <14629.1751.688160.645952@na19>
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);