This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Apparent erratic rescanning of ,##<varargs> construct in cpp 3.2.x


This input:
--------------------------------------------------------------------------
#define a(x,...) a1(x,__VA_ARGS__)
#define b(x,...) b1(x,##__VA_ARGS__)

a(a(1,2),a(3,4)) //1
a(a(1,2),b(3,4)) //2
b(b(1,2),a(3,4)) //3
b(b(1,2),b(3,4)) //4
--------------------------------------------------------------------------

macro-expands differently (and less usefully) in case 4 from cases 1-3 - note that the last occurrence of b() did not expand in the following output. I do not believe this should be the case.
--------------------------------------------------------------------------
$ gcc -E t.c
# 1 "t.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t.c"




a1(a1(1,2),a1(3,4)) //1
a1(a1(1,2),b1(3,4)) //2
b1(b1(1,2),a1(3,4)) //3
b1(b1(1,2),b(3,4)) //4
--------------------------------------------------------------------------

The problem was discovered under MinGW:
--------------------------------------------------------------------------
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\>gcc -v
Reading specs from c:/progra~1/other/mingw/bin/../lib/gcc-lib/mingw32/3.2.3/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c++,f77,objc --disable-win32-registry --disable-shared --enable-sjlj-exceptions
Thread model: win32
gcc version 3.2.3 (mingw special 20030504-1)
--------------------------------------------------------------------------


But it is exactly reproducible under Linux:
--------------------------------------------------------------------------
[stephen@tifa stephen]$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
--------------------------------------------------------------------------


I'm afraid I don't presently have a more recent gcc available to test on.

Thanks and keep up the good work.

Stephen P Spackman

X bitmap


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]