Bug 31182 - preprocessor doubles up digits in token pasting
Summary: preprocessor doubles up digits in token pasting
Status: RESOLVED DUPLICATE of bug 28709
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-15 03:30 UTC by David Boyce
Modified: 2007-04-25 01:29 UTC (History)
5 users (show)

See Also:
Host: i386-pc-solaris2.10
Target: i386-pc-solaris2.10
Build: i386-pc-solaris2.10
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Boyce 2007-03-15 03:30:48 UTC
Very simple test case:

% cat /tmp/ff.s
#define Concat(a,b)     a##b
Concat(foo,2.2)

% cpp -P /tmp/ff.s
foo22.2

Notice that what should be "2.2" becomes "22.2". Also note that this occurs while preprocessing assembler (-x assembler-with-cpp) code.
Comment 1 David Fang 2007-03-15 04:35:34 UTC
Subject: Re:  preprocessor doubles up digits in token
 pasting

With your example, "g++ -E -"

gives me:
<stdin>:2:1: error: pasting "foo2" and "2.2" does not give a valid
preprocessing token
foo22.2

with versions 4.0.1 (powerpc-apple-darwin8)
and 4.2.0 (20070221)


while "cpp -P" (4.0.1) gives me
foo##2.2

and "cpp -P" (4.2.0) gives me
<stdin>:2:1: error: pasting "foo" and "2.2" does not give a valid
preprocessing token
foo22.2

and "cpp -P -traditional" (4.0.1, 4.2.0) give me
foo##2.2


Most odd...

Comment 2 David Boyce 2007-03-15 12:42:29 UTC
This is because the default behavior is to preprocess in C mode but as I mentioned it happens in assembler mode. If you add the flag '-x assembler-with-cpp' you should see the reported result. My test case was in a file with a .s extension which causes cpp/gcc to infer '-x assembler-with-cpp'.
Comment 3 David Boyce 2007-03-15 12:44:07 UTC
(when I said "this" I meant to refer to the "invalid token" warnings)
Comment 4 Tom Tromey 2007-03-15 16:28:26 UTC
I think this is probably the same thing as bug #28709,
and most likely fixed by the same patch.
Comment 5 David Boyce 2007-03-16 12:58:34 UTC
I just downloaded the latest 4.2 snapshot (gcc-4.2-20070307) and built it but the behavior is the same. Given that the bugfix cited there dates back to October and that it says "Known to work: 4.2.0"  I assume the patch is present here so it appears to be different from http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28709
Comment 6 Tom Tromey 2007-04-25 01:29:01 UTC
This is fixed by the follow-on patch in PR 28709, see:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28709#c5


*** This bug has been marked as a duplicate of 28709 ***