From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14495 invoked by alias); 1 Jul 2002 19:46:10 -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 14429 invoked by uid 71); 1 Jul 2002 19:46:08 -0000 Resent-Date: 1 Jul 2002 19:46:08 -0000 Resent-Message-ID: <20020701194608.14428.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, dobrynin@bigfoot.com Received: (qmail 9155 invoked by uid 61); 1 Jul 2002 19:42:47 -0000 Message-Id: <20020701194247.9154.qmail@sources.redhat.com> Date: Mon, 01 Jul 2002 12:46:00 -0000 From: dobrynin@bigfoot.com Reply-To: dobrynin@bigfoot.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/7178: "CONST" pre-processed to "const" -- case problem (pre-processing bug) X-SW-Source: 2002-07/txt/msg00013.txt.bz2 List-Id: >Number: 7178 >Category: c++ >Synopsis: "CONST" pre-processed to "const" -- case problem (pre-processing bug) >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: accepts-illegal >Submitter-Id: net >Arrival-Date: Mon Jul 01 12:46:07 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Nickolai Dobrynin, University of WI-Milwaukee >Release: gcc version 3.1 >Organization: >Environment: Windows 2000 Pro, Pentium 3, Dell Dimension the options given when GCC was configured/built: Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host= mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable -languages=f77,c++,objc,ada --disable-win32-registry --disable-shared the compiler output (error messages, warnings, etc.): bug1.cpp:7: declaration does not declare anything bug1.cpp:7: duplicate `const' bug1.cpp:7: storage class specified for typename bug1.cpp:7: parse error before `=' token bug1.cpp: In function `int main()': bug1.cpp:18: parse error before `const' the complete command line that triggers the bug: g++ -Wall -save-temps bug1.cpp the preprocessed file (*.i*) that triggers the bug, generated by adding -save-temps to the complete compilation command: NOTE: this is (to the best of my knowledge) a pre-processor bug, so there is an official excuse for not sending the pre-processed version. >Description: This is simultaneously an accepts-illegal-rejects-legal problem. It seems pretty clear that this is a pre-processor bug. Indeed, in the pre-processed version, "static int const CONST = 3;" is converted into "static int const const = 3;". IMPORTANT: if the line in "main" that reads cout << "foo::CONST = " << foo::CONST << endl; is removed, then the line "static int const CONST = 3;" is accepted. Considering that this previous line is pre-processed as "static int const const = 3;", this may mean a bug elsewhere in the system: the combination "const const" is definitely illegal in this context. >How-To-Repeat: The original file bug1.cpp follows. ********************************** #include using namespace std; class foo { public: // The following causes an error later. static int const CONST = 3; // The following compiles, though it probably shouldn't. static int CONST c = 4; }; int main() { // The following doesn't compile, though it should! // It complains about "static int const CONST = 3;" above. cout << "foo::CONST = " << foo::CONST << endl; // If the previous line is removed, then "static int const CONST = 3;" // would compile but this would be useless... :( cout << "foo::c = " << foo::c << endl; return 0; } // It seems pretty clear that this is a pre-processor bug. // Indeed, in the pre-processed version, // "static int const CONST = 3;" is converted into // "static int const const = 3;". // // IMPORTANT: if the line in "main" that reads // cout << "foo::CONST = " << foo::CONST << endl; // is removed, then the line "static int const CONST = 3;" // is accepted. Considering that this previous line is // pre-processed as "static int const const = 3;", // this may mean a bug elsewhere in the system: // the combination "const const" is definitely illegal // in this context. >Fix: >Release-Note: >Audit-Trail: >Unformatted: