This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: c++/2957: -pedantic: parse error


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).





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]