c++/2957: -pedantic: parse error
Artem Khodush
artem@duma.gov.ru
Mon May 28 03:41:00 GMT 2001
Matthias Klose wrote:
>
> example below compiled witch -pedantic makes:
>
> $ g++-3.0 -pedantic foo.cc
> foo.cc: In function `int foo()':
> foo.cc:8: parse error before `;' token
>
> w/o -pedantic it is ok.
>
>
> #include <vector>
>
> using namespace std;
>
> template<class T>
> int foo()
> {
> vector<T>::iterator i; /* this line: parse error before ';' */
> }
standard-conforming code must use typename here:
typename vector<T>::iterator i;
but gcc detects this only in pedantic mode.
(the compiler does not know that vector<T>::iterator is always a type
for an arbitrary value of T, hence the parse error).
More information about the Gcc-bugs
mailing list