public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* preprocessor/7976: macro definition
@ 2002-09-19  4:46 stoppel
  0 siblings, 0 replies; 5+ messages in thread
From: stoppel @ 2002-09-19  4:46 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7976
>Category:       preprocessor
>Synopsis:       macro definition
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 19 04:46:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     National Bank of Poland
>Release:        gcc version 3.1
>Organization:
>Environment:
HPUX 10.20 hw:K460, HPUX 11.00 hw:J5000, GNU/Linux Debian 2.2.17
>Description:
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
> 
>How-To-Repeat:
"cpp-define.c" is the attached file
gcc -E cpp cpp-define.c
cpp cpp-define.c
>Fix:
I do not know.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="cpp-define.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="cpp-define.c"

CiBUaGlzIGNvZGUgaXMgdGhlIGV4Y2VycHQgZnJvbQogaHB1eC0xMC4yMDovdXNyL2luY2x1ZGUv
aW5pdHR5cGVzLmgKCiBJIGV4cGVjdGVkIHRoZSBtYWNybyBjYWxsICJVSU5UMzJfQygxMjMpIgog
dG8gcmV0dXJuICIxMjN1bCIgYnV0IGl0IHByb2R1Y2UgIjEyM3UgbCIuCiBUaGUgc2FtZSByZXN1
bHQgSSBvYnRhaW5lZCBvbiBMaW51eC4KIFRoZSBIUFVYIGFuc2ljIHJldHVybnMgdGhlIGV4cGVj
dGVkICIxMjN1bCIuCgogSSBwcm9jZXNzZWQgdGhpcyBmaWxlIGJ5OgoJZ2NjIC1FIGNwcC1kZWZp
bmUuYwoJY3BwIGNwcC1kZWZpbmUuYwoKICJjcHAiIHJlcG9ydHM6Cj4KPiBjcHAtZGVmaW5lLmM6
MjI6MTMgd2FybmluZzogcGFzdGluZyAiKSIgYW5kICJsIgo+IGRvZXMgbm90IGdpdmUgYSB2YWxp
ZCBwcmVwcm9jZXNzaW5nIHRva2VuCj4KCiNkZWZpbmUgX19DT05DQVRfXyhfQSxfQikgX0EgIyMg
X0IKI2RlZmluZSBfX0NPTkNBVF9VX18oX0EpIF9BICMjIHUKI2RlZmluZSBVSU5UMzJfQyhfX2Mp
IF9fQ09OQ0FUX18oX19DT05DQVRfVV9fKF9fYyksbCkKClVJTlQzMl9DKDEyMykKCg==


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: preprocessor/7976: macro definition
@ 2002-09-19  6:46 Andreas Schwab
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Schwab @ 2002-09-19  6:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1212 bytes --]

The following reply was made to PR preprocessor/7976; it has been noted by GNATS.

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."


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: preprocessor/7976: macro definition
@ 2002-09-19  6:20 neil
  0 siblings, 0 replies; 5+ messages in thread
From: neil @ 2002-09-19  6:20 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, stoppel

Synopsis: macro definition

State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Thu Sep 19 06:19:59 2002
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.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7976


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: preprocessor/7976: macro definition
@ 2002-09-19  6:13 neil
  0 siblings, 0 replies; 5+ messages in thread
From: neil @ 2002-09-19  6:13 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, stoppel

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.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7976


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: preprocessor/7976: macro definition
@ 2002-09-19  6:11 neil
  0 siblings, 0 replies; 5+ messages in thread
From: neil @ 2002-09-19  6:11 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, stoppel

Synopsis: macro definition

State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Thu Sep 19 06:11:22 2002
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.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7976


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-09-19 13:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-19  4:46 preprocessor/7976: macro definition stoppel
2002-09-19  6:11 neil
2002-09-19  6:13 neil
2002-09-19  6:20 neil
2002-09-19  6:46 Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).