Bug in g++ using -pedantic option.
Geir Bjarte Terum
gb@funcom.com
Wed May 12 08:28:00 GMT 1999
// Show bug: g++ -Wall -ansi -pedantic -DFORCE_BUG=1 pedantic_bug.cpp
// Hide bug: g++ -Wall -ansi -pedantic -DFORCE_BUG=0 pedantic_bug.cpp
//
// Versions:
// gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
// gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
//
// Platforms:
// * Digital Unix
// * IRIX
// * Linux
class MC {
};
#if FORCE_BUG==1
// The second param causes the trouble.
template <class T, class M=MC()> class A {
#else
template <class T> struct A {
#endif
typedef T value;
};
template <class T> struct B: public A<T> {
B(value v): v(v) {} // Here starts the fun using -pedantic and
FORCE_BUG!
value v;
};
int main() {
B<int> b1(37);
return b1.v;
}
// Compiler output: (-pedantic -DFORCE_BUG=1)
// ----------------
// pedantic_bug.cpp:21: parse error before `v'
// pedantic_bug.cpp:21: missing ';' before right brace
// pedantic_bug.cpp:22: syntax error before `;'
// pedantic_bug.cpp:22: warning: ANSI C++ forbids declaration `v' with
no type
// pedantic_bug.cpp: In function `int main()':
// pedantic_bug.cpp:26: no matching function for call to `B<int>::B
(int)'
// pedantic_bug.cpp:26: candidates are: B<int>::B(const B<int> &)
// pedantic_bug.cpp:26: B<int>::B()
// pedantic_bug.cpp:27: `struct B<int>' has no member named `v'
// pedantic_bug.cpp:28: warning: control reaches end of non-void
function `main()'
- gb -
More information about the Gcc-bugs
mailing list