From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16885 invoked by alias); 19 Feb 2003 22:16: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 16861 invoked by uid 71); 19 Feb 2003 22:15:59 -0000 Resent-Date: 19 Feb 2003 22:15:59 -0000 Resent-Message-ID: <20030219221559.16860.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, rpm31@student.canterbury.ac.nz Received: (qmail 13359 invoked by uid 48); 19 Feb 2003 22:10:30 -0000 Message-Id: <20030219221030.13358.qmail@sources.redhat.com> Date: Wed, 19 Feb 2003 22:16:00 -0000 From: rpm31@student.canterbury.ac.nz Reply-To: rpm31@student.canterbury.ac.nz To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: preprocessor/9764: Varargs macro extension incorrectly expands if the varargs argument is the macro itself X-SW-Source: 2003-02/txt/msg00960.txt.bz2 List-Id: >Number: 9764 >Category: preprocessor >Synopsis: Varargs macro extension incorrectly expands if the varargs argument is the macro itself >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Wed Feb 19 22:15:59 UTC 2003 >Closed-Date: >Last-Modified: >Originator: rpm31@student.canterbury.ac.nz >Release: gcc version 2.95.2 19991024 (release) >Organization: >Environment: SunOS 5.9 Generic sun4u sparc Reading specs from /usr/local/gnu/pkg/gcc/2.95.2/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs gcc version 2.95.2 19991024 (release) /usr/local/gnu/pkg/gcc/2.95.2/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/cpp -lang-c -v -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) - GNU CPP version 2.95.2 19991024 (release) (sparc) #include "..." search starts here: #include <...> search starts here: /usr/local/gnu/pkg/gcc/2.95.2/include /usr/local/gnu/pkg/gcc/2.95.2/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/../../../../sparc-sun-solaris2.7/include /usr/local/gnu/pkg/gcc/2.95.2/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/include /usr/include End of search list. The following default directories have been omitted from the search path: /usr/local/gnu/pkg/gcc/2.95.2/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/../../../../include/g++-3 End of omitted list. >Description: When using the varargs macro extension, the preprocessor incorrectly expands the macro if one of the variable arguments is the macro name itself. The problem does not occur if the macro name is used as one of the other arguments or if another macro definition is used as one of the varargs arguments. The problem does not occur if the token paste (for allowing no variable arguments) is ommitted. >How-To-Repeat: #define func(a, varargs...) _func(a, ##b) func(a, func(a, b)); Expands as: _func(a, func(a, b)) >Fix: Workaround hacks include using two macros (one for the call and one for the argument), removing the token paste operator (this reduces flexibility however) and preprocessing twice (yuck). >Release-Note: >Audit-Trail: >Unformatted: