From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12066 invoked by alias); 3 Apr 2013 17:31:33 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 12013 invoked by uid 48); 3 Apr 2013 17:31:28 -0000 From: "harald at gigawatt dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/56825] Preprocessor does not expand macro correctly if it is an argument and argument of a macro contains ## Date: Wed, 03 Apr 2013 17:31:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: harald at gigawatt dot nl X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 X-SW-Source: 2013-04/txt/msg00325.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56825 Harald van Dijk changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |harald at gigawatt dot nl --- Comment #3 from Harald van Dijk 2013-04-03 17:31:26 UTC --- For the related #define foo(x, y) x ## y both foo(f,oo(,)) and foo(,foo(,)) expand similarly to foo(,) and in that case, that is the only valid expansion in standard C (C99, anyway). The macro argument foo(,) is not expanded during argument substitution because it is an operand of a ## operator. The macro argument is not expanded after argument substitution because that happens in the context of another expansion of the same foo macro. > But IMHO this statement is relevant to the macro itself and should not apply to the argument of the macro That is exactly what it is meant to apply to. #define A 1 #define B 2 #define AB 3 #define C(a, b) a ## b C(A, B) must expand to 3. Neither A nor B is allowed to be expanded here before concatenation takes place. AB must be expanded after that, as long as no other expansion of AB is already taking place. That said, , ## x is a GNU extension that never concatenates (except for the rare case where x is an empty macro argument), so the standard cannot and does not require it to behave exactly the same way as the concatenation operator.