Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 7976
Product:  
Component:  
Status: RESOLVED
Resolution: INVALID
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: stoppel@immt.pwr.wroc.pl
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
cpp-define.c cpp-define.c application/octet-stream 2003-05-21 15:17 341 bytes Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 7976 depends on: Show dependency tree
Show dependency graph
Bug 7976 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2002-09-19 04:46
Execution of some mocro definition yield unexpected results:
"cpp" reports:
> 
> cpp-define.c:22:13 warning: pasting ")" and "l"
> does not give a valid preprocessing token
>

Release:
gcc version 3.1

Environment:
HPUX 10.20 hw:K460, HPUX 11.00 hw:J5000, GNU/Linux Debian 2.2.17

How-To-Repeat:
"cpp-define.c" is the attached file
gcc -E cpp cpp-define.c
cpp cpp-define.c

------- Comment #1 From stoppel@immt.pwr.wroc.pl 2002-09-19 04:46 -------
Fix:
I do not know.

------- Comment #2 From Neil Booth 2002-09-19 06:11 -------
State-Changed-From-To: open->closed
State-Changed-Why: Not a bug.  You have a ## in your macro definition that
    is being used to create a token from ")" and "l" by
    concatenation.  No such token exists.
    
    You can probably remove the ## in question.

------- Comment #3 From Neil Booth 2002-09-19 06:13 -------
State-Changed-From-To: closed->open
State-Changed-Why: Sorry, ignore previous message.  I'll look at this later.

------- Comment #4 From Neil Booth 2002-09-19 06:19 -------
State-Changed-From-To: open->closed
State-Changed-Why: Not a bug.
    
    #define __CONCAT__(_A,_B) _A ## _B
    #define __CONCAT_U__(_A) _A ## u
    #define UINT32_C(__c) __CONCAT__(__CONCAT_U__(__c),l)
    UINT32_C(123)
    
    The bug in your macro occurs during the expansion of UINT32_C.  Since, in the definition of __CONCAT__, the
    first argument is operated on by ##, it is not expanded
    before replacement.  Therefore, the first stage of
    expansion is
    UINT32_C(123)
    __CONCAT__(__CONCAT_U__(123),l)
    __CONCAT_U__(123)##l
    
    which is not what you want, and gives rise to the (correct)
    warning you see.  You want the argument to be
    expanded, and so you need an extra level of indirection:
    
    #define __CONCAT_INDIRECT(_A,_B) __CONCAT(_A,_B)
    #define __CONCAT__(_A,_B) _A ## _B
    #define __CONCAT_U__(_A) _A ## u
    #define UINT32_C(__c) _CONCAT_INDIRECT__(__CONCAT_U__(__c),l)
    UINT32_C(123)
    
    If HPUX AnsiC gives the answer you wanted, then it's simply
    not ANSI 8-)
    
    Neil.

------- Comment #5 From Andreas Schwab 2002-09-19 15:45 -------
From: Andreas Schwab <schwab@suse.de>
To: neil@gcc.gnu.org
Cc: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org,
	stoppel@immt.pwr.wroc.pl, gcc-gnats@gcc.gnu.org
Subject: Re: preprocessor/7976: macro definition
Date: Thu, 19 Sep 2002 15:45:21 +0200

 neil@gcc.gnu.org writes:
 
 |> Synopsis: macro definition
 |> 
 |> State-Changed-From-To: closed->open
 |> State-Changed-By: neil
 |> State-Changed-When: Thu Sep 19 06:13:38 2002
 |> State-Changed-Why:
 |>     Sorry, ignore previous message.  I'll look at this later.
 
 IMHO your previous analysis was right.
 
 UINT32_C(123) ->
 __CONCAT__(__CONCAT_U__(123),l) ->
 __CONCAT_U__(123) ## l
 
 and )l is not a token.  This needs to be written like this:
 
 #define __CONCAT2__(_A,_B) _A ## _B
 #define __CONCAT__(_A,_B) __CONCAT2__(_A,_B)
 #define __CONCAT_U__(_A) _A ## u
 #define UINT32_C(__c) __CONCAT__(__CONCAT_U__(__c),l)
 
 Andreas.
 
 -- 
 Andreas Schwab, SuSE Labs, schwab@suse.de
 SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
 Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
 "And now for something completely different."

------- Comment #6 From Andrew Pinski 2004-09-02 20:34 -------
*** Bug 17299 has been marked as a duplicate of this bug. ***

------- Comment #7 From Andrew Pinski 2004-09-02 20:34 -------
*** Bug 16275 has been marked as a duplicate of this bug. ***

------- Comment #8 From Andrew Pinski 2004-09-02 20:35 -------
*** Bug 12513 has been marked as a duplicate of this bug. ***

------- Comment #9 From Andrew Pinski 2004-09-02 20:37 -------
*** Bug 9689 has been marked as a duplicate of this bug. ***

------- Comment #10 From Andrew Pinski 2004-09-02 20:38 -------
Reopening to mark as ...

------- Comment #11 From Andrew Pinski 2004-09-02 20:38 -------
Not a bug.

------- Comment #12 From Andrew Pinski 2004-09-03 08:23 -------
*** Bug 17304 has been marked as a duplicate of this bug. ***

------- Comment #13 From Andrew Pinski 2004-09-03 09:26 -------
*** Bug 17304 has been marked as a duplicate of this bug. ***

------- Comment #14 From Andrew Pinski 2005-09-28 04:02 -------
*** Bug 24098 has been marked as a duplicate of this bug. ***

------- Comment #15 From Andrew Pinski 2005-09-28 04:05 -------
*** Bug 17638 has been marked as a duplicate of this bug. ***

------- Comment #16 From Andrew Pinski 2005-09-28 04:05 -------
*** Bug 12607 has been marked as a duplicate of this bug. ***

------- Comment #17 From PLANTA 2005-09-28 14:35 -------
Subject: AW:  macro definition

Stopp blaming us!!!

Remove us immediatelly from cc List.

Thx!


 -----Ursprüngliche Nachricht-----
Von: 	pinskia at gcc dot gnu dot org [mailto:gcc-bugzilla@gcc.gnu.org] 
Gesendet:	Mittwoch, 28. September 2005 06:06
An:	planta
Betreff:	[Bug preprocessor/7976] macro definition


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-28 04:05 -------
*** Bug 12607 has been marked as a duplicate of this bug. ***


------- Comment #18 From Diego Novillo 2005-09-28 14:40 -------
 
As requested in comment #17 

------- Comment #19 From Andrew Pinski 2005-11-30 01:33 -------
*** Bug 25170 has been marked as a duplicate of this bug. ***

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug