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]

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


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


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