This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/2957: -pedantic: parse error
- To: <gcc-gnats at gcc dot gnu dot org>
- Subject: Re: c++/2957: -pedantic: parse error
- From: "Artem Khodush" <artem at duma dot gov dot ru>
- Date: Mon, 28 May 2001 14:30:49 +0400
- >Received: from artem by mailsrv.duma.gov.ru (SMI-8.6/SMI-SVR4)id OAA12496; Mon, 28 May 2001 14:33:40 +0400
- Cc: <87000-quiet at bugs dot debian dot org>, <gcc-bugs at gcc dot gnu dot org>
- References: <E153iTG-0001mf-00@smile.cs.tu-berlin.de>
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).