This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/10829: Macros that worked in 2.95.3 don't work in 3.3


>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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]