Preprocessor bug

Martin Sebor sebor@roguewave.com
Mon Nov 20 19:12:00 GMT 2000


John Hinke wrote:
> 
> Hi,
> 
> I've got a small problem with the GCC preprocessor.  I'm using a recent (1
> week old) pull from CVS that demonstrates the problem.  Here is the code
> that fails:

It's a recent regression, too. gcc-20001002 does the right thing (at
least according to my reading of 6.10.3.4 of C99). You should probably
enter it in GNATS so it doesn't get lost.

Cheers
Martin

> 
> #define name2(a,b)  tmpname2(a,b)
> #define tmpname2(a,b) a##b
> 
> #define declare(Class,type)  name2(Class,declare)(type)
> 
> #define MyClassdeclare(type) name2(type,MyClass)
> 
> declare(MyClass,int)
> 
> Executing "g++ -E bug.cpp" produces:
> 
> # 1 "bug.cpp"
> # 11 "bug.cpp"
> name2(int,MyClass)
> 
> However, executing the same line using G++ V2.95.2 produces (which is the
> expected output):
> # 1 "bug.cpp"
> 
>        intMyClass
> 
> Any comments?  If I'm doing something wrong, please let me know.  This code
> has been working for many years now.  Also, other compilers that I tested
> produce the correct (2.95.2) output.
> 
> Thanks,
> 
> John


More information about the Gcc-bugs mailing list