[Bug c++/14965] New: Missing template keyword after scope operator leading to weird error, meybe even segfault
arno at mpi-sb dot mpg dot de
gcc-bugzilla@gcc.gnu.org
Thu Apr 15 14:06:00 GMT 2004
The enclosed example program fails to be legal C++ because of a missing
'template' keyword after a scope operator ::. However, the error message
emitted by g++ 3.3.3 is completely wrong, and a similar mistake in a
program of several 10000 lines of code even causes an internal compiler
error (segmentation fault) which I could not reproduce in a short example.
I'm reporting the small example because I suspect that both problems are
effects of the same cause.
Thank you in advance.
Error message:
example.C: In member function `void Example<Type_traits>::f() [with Type_traits
= Int_traits]':
example.C:37: instantiated from here
example.C:30: error: no match for call to `(
C<Int_traits>::Fortytwo_functor<int>) (C<int>&)'
example.C:7: error: candidates are: TArg2
C<TArg1>::Fortytwo_functor<TArg2>::operator()(C<TArg1>) [with TArg2 = int,
TArg1 = Int_traits]
(Notice that the template argument to C<> is reported wrongly every time.)
Complete source code:
template <class TArg1>
class C {
public:
template <class TArg2>
class Fortytwo_functor {
public:
TArg2 operator() (C) { return TArg2(42); }
};
};
class Int_traits {
public:
typedef int Chosen_type;
};
template <class Type_traits>
class Example {
public:
typedef typename Type_traits::Chosen_type T;
void f() {
typedef C<T> My_C;
My_C c;
// this version compiles correctly
// typename My_C::template Fortytwo_functor<T> ftf;
// this version exposes the problem:
typename My_C::Fortytwo_functor<T> ftf;
int ft= ftf(c);
}
};
int main(int, char**) {
typedef Example<Int_traits> Example;
Example ex;
ex.f();
return 0;
}
// EOF
Complete compiler argument and version information:
gcc-3.3.3 example.C -o example -lstdc++ -L/usr/local/gcc-3.3/gcc-3.3.3/lib
-Wl,-R/usr/local/gcc-3.3/gcc-3.3.3/lib -save-temps -v
Reading specs from
/usr/local/gcc-3.3/gcc-3.3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs
Configured with: ./configure --prefix=/usr/local/gcc-3.3/gcc-3.3.3
--program-suffix=-3.3.3 --enable-languages=c,c++ : (reconfigured) ./configure
--prefix=/usr/local/gcc-3.3/gcc-3.3.3 --program-suffix=-3.3.3
--enable-languages=c,c++ : (reconfigured) ./configure
--prefix=/usr/local/gcc-3.3/gcc-3.3.3 --program-suffix=-3.3.3
--enable-languages=c,c++
Thread model: posix
gcc version 3.3.3
--
Summary: Missing template keyword after scope operator leading to
weird error, meybe even segfault
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: arno at mpi-sb dot mpg dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14965
More information about the Gcc-bugs
mailing list