public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7178: "CONST" pre-processed to "const" -- case problem (pre-processing bug)
@ 2002-10-26 7:35 lerdsuwa
0 siblings, 0 replies; 2+ messages in thread
From: lerdsuwa @ 2002-10-26 7:35 UTC (permalink / raw)
To: dobrynin, gcc-bugs, gcc-prs, nobody
Synopsis: "CONST" pre-processed to "const" -- case problem (pre-processing bug)
State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Sat Oct 26 07:35:34 2002
State-Changed-Why:
Not a bug. It appears that "CONST" is defined to be "const" on your platform by some system header. So "CONST" should not be used as a variable name there.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7178
^ permalink raw reply [flat|nested] 2+ messages in thread
* c++/7178: "CONST" pre-processed to "const" -- case problem (pre-processing bug)
@ 2002-07-01 12:46 dobrynin
0 siblings, 0 replies; 2+ messages in thread
From: dobrynin @ 2002-07-01 12:46 UTC (permalink / raw)
To: gcc-gnats
>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:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-10-26 14:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-26 7:35 c++/7178: "CONST" pre-processed to "const" -- case problem (pre-processing bug) lerdsuwa
-- strict thread matches above, loose matches on Subject: below --
2002-07-01 12:46 dobrynin
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).