public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: dobrynin@bigfoot.com To: gcc-gnats@gcc.gnu.org Subject: c++/7178: "CONST" pre-processed to "const" -- case problem (pre-processing bug) Date: Mon, 01 Jul 2002 12:46:00 -0000 [thread overview] Message-ID: <20020701194247.9154.qmail@sources.redhat.com> (raw) >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 <iostream> 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:
next reply other threads:[~2002-07-01 19:46 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-07-01 12:46 dobrynin [this message] 2002-10-26 7:35 lerdsuwa
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020701194247.9154.qmail@sources.redhat.com \ --to=dobrynin@bigfoot.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).