public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/10829: Macros that worked in 2.95.3 don't work in 3.3
@ 2003-05-17  5:31 zack
  0 siblings, 0 replies; 5+ messages in thread
From: zack @ 2003-05-17  5:31 UTC (permalink / raw)
  To: aaronw, gcc-bugs, gcc-prs, nobody

Synopsis: Macros that worked in 2.95.3 don't work in 3.3

State-Changed-From-To: open->closed
State-Changed-By: zack
State-Changed-When: Sat May 17 05:31:38 2003
State-Changed-Why:
    Reporter's code is ill-formed.  Diagnostics are correct.

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


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

* Re: c/10829: Macros that worked in 2.95.3 don't work in 3.3
@ 2003-05-17  6:26 Zack Weinberg
  0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2003-05-17  6:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: Zack Weinberg <zack@codesourcery.com>
To: "Aaron Williams" <aaron_williams@net.com>
Cc: aaronw@net.com,  gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c/10829: Macros that worked in 2.95.3 don't work in 3.3
Date: Fri, 16 May 2003 23:18:21 -0700

 "Aaron Williams" <aaron_williams@net.com> writes:
 
 > Thanks for the quick response.  I might add that the code I submitted
 > also compiles fine with Sun's Forte 6.1 C++ compiler.
 
 You did get the longer explanation I sent, yes?
 
 zw


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

* Re: c/10829: Macros that worked in 2.95.3 don't work in 3.3
@ 2003-05-17  6:16 Aaron Williams
  0 siblings, 0 replies; 5+ messages in thread
From: Aaron Williams @ 2003-05-17  6:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: "Aaron Williams" <aaron_williams@net.com>
To: zack@gcc.gnu.org, aaronw@net.com, gcc-bugs@gcc.gnu.org,
   gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c/10829: Macros that worked in 2.95.3 don't work in 3.3
Date: Fri, 16 May 2003 23:08:08 -0700

 Thanks for the quick response.  I might add that the code I submitted 
 also compiles fine with Sun's Forte 6.1 C++ compiler.
 
 -Aaron
 
 zack@gcc.gnu.org wrote:
 
 >Synopsis: Macros that worked in 2.95.3 don't work in 3.3
 >
 >State-Changed-From-To: open->closed
 >State-Changed-By: zack
 >State-Changed-When: Sat May 17 05:31:38 2003
 >State-Changed-Why:
 >    Reporter's code is ill-formed.  Diagnostics are correct.
 >
 >http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10829
 >  
 >
 


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

* Re: c/10829: Macros that worked in 2.95.3 don't work in 3.3
@ 2003-05-17  5:26 Zack Weinberg
  0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2003-05-17  5:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: Zack Weinberg <zack@codesourcery.com>
To: aaronw@net.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c/10829: Macros that worked in 2.95.3 don't work in 3.3
Date: Fri, 16 May 2003 22:25:46 -0700

 aaronw@net.com writes:
 
 > #define TEST(t, num) (PAP_ ## t ## (c->PAT_ ## t ## ( ## num ## )))
 
 Your code is not valid: the C standard clearly states that applying ##
 to two tokens whose concatenation does not form a single valid token
 provokes undefined behavior.  There is nothing that can be combined
 with a ( or a ) to produce a single valid token, except a "placemarker"
 which occurs only under exotic conditions.
 
 A correct version of your macro would be
 
   #define TEST(t, num) (PAP_ ## t (c->PAT_ ## t (num)))
 
 This expands exactly the same way, but does not give the warnings.
 
 Rule of thumb: if the things on either side of ##, after argument
 substitution, are not identifiers or pp-numbers, you have made a
 mistake.  This is overbroad -- one may legitimately paste together 
 a + and an = in that order, for instance -- but covers all the normal
 uses of ##.
 
 zw


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

* c/10829: Macros that worked in 2.95.3 don't work in 3.3
@ 2003-05-17  4:36 aaronw
  0 siblings, 0 replies; 5+ messages in thread
From: aaronw @ 2003-05-17  4:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         10829
>Category:       c
>Synopsis:       Macros that worked in 2.95.3 don't work in 3.3
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Sat May 17 04:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Aaron Williams
>Release:        3.3
>Organization:
>Environment:
Solaris 2.7, 32-bit Ultrasparc
>Description:
When I compile the attached file with gcc 2.95.3 everything works fine.  When I try and compile with gcc 3.3 I get the following error:

test.c:15:19: pasting "PAP_int" and "(" does not give a valid preprocessing token
test.c:15:19: pasting "PAT_int" and "(" does not give a valid preprocessing token
test.c:15:19: pasting "(" and "1" does not give a valid preprocessing token
test.c:15:19: pasting "1" and ")" does not give a valid preprocessing token


The contents of the test file are:

#include <stdio.h>

typedef struct {
    int val1, val2, val3;
} s_t;

#define PAT_int(num) val ## num
#define PAP_int

#define TEST(t, num) (PAP_ ## t ## (c->PAT_ ## t ## ( ## num ## )))

int func(s_t *c)
{
    int n;
    n = TEST(int,1);
    return n+1;
}

int main(int argc, char *argv[])
{
    s_t c;
    int a;

    c.val1 = 10;
    a = func(&c);
    printf("Result is %d\n", a);
}

When compiled with gcc 2.95.3 it works correctly and prints out "Result is 11".
>How-To-Repeat:
Attempt to compile the above code with gcc 3.3
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-csrc; name="test.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.c"

I2luY2x1ZGUgPHN0ZGlvLmg+Cgp0eXBlZGVmIHN0cnVjdCB7CiAgICBpbnQgdmFsMSwgdmFsMiwg
dmFsMzsKfSBzX3Q7CgojZGVmaW5lIFBBVF9pbnQobnVtKSB2YWwgIyMgbnVtCiNkZWZpbmUgUEFQ
X2ludAoKI2RlZmluZSBURVNUKHQsIG51bSkgKFBBUF8gIyMgdCAjIyAoYy0+UEFUXyAjIyB0ICMj
ICggIyMgbnVtICMjICkpKQoKaW50IGZ1bmMoc190ICpjKQp7CiAgICBpbnQgbjsKICAgIG4gPSBU
RVNUKGludCwxKTsKICAgIHJldHVybiBuKzE7Cn0KCmludCBtYWluKGludCBhcmdjLCBjaGFyICph
cmd2W10pCnsKICAgIHNfdCBjOwogICAgaW50IGE7CgogICAgYy52YWwxID0gMTA7CiAgICBhID0g
ZnVuYygmYyk7CiAgICBwcmludGYoIlJlc3VsdCBpcyAlZFxuIiwgYSk7Cn0K


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

end of thread, other threads:[~2003-05-17  6:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-17  5:31 c/10829: Macros that worked in 2.95.3 don't work in 3.3 zack
  -- strict thread matches above, loose matches on Subject: below --
2003-05-17  6:26 Zack Weinberg
2003-05-17  6:16 Aaron Williams
2003-05-17  5:26 Zack Weinberg
2003-05-17  4:36 aaronw

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