This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/7178: "CONST" pre-processed to "const" -- case problem (pre-processing bug)
- From: dobrynin at bigfoot dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 1 Jul 2002 19:42:47 -0000
- Subject: c++/7178: "CONST" pre-processed to "const" -- case problem (pre-processing bug)
- Reply-to: dobrynin at bigfoot dot com
>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: