From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4786 invoked by alias); 17 May 2003 05:26:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 4772 invoked by uid 71); 17 May 2003 05:26:00 -0000 Date: Sat, 17 May 2003 05:26:00 -0000 Message-ID: <20030517052600.4771.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Zack Weinberg Subject: Re: c/10829: Macros that worked in 2.95.3 don't work in 3.3 Reply-To: Zack Weinberg X-SW-Source: 2003-05/txt/msg01931.txt.bz2 List-Id: The following reply was made to PR c/10829; it has been noted by GNATS. From: Zack Weinberg 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