This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
G++ Bug with option -pedantic
- To: gcc-bugs at gcc dot gnu dot org
- Subject: G++ Bug with option -pedantic
- From: kanze at gabi-soft dot de
- Date: Sun, 7 May 2000 22:43:07 +0200 (MET DST)
The attached source doesn't compile with the -pedantic-errors option,
at least under Windows. Even with the most pedantic interpretation
possible, I don't see any error.
Compiler output:
-----------------------------------------------------------------------------
> g++ vci.cc -v -c -pedantic-errors
g++ vci.cc -v -c -pedantic-errors
Reading specs from /Program/Cygnus/cygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95/specs
gcc version 2.95 19990728 (release)
/Program/Cygnus/cygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95/cpp.exe -lang-c++ -v -iprefix /Program/Cygnus/cygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95/ -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Di386 -D_WIN32 -DWINNT -D_X86_=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -D__i386__ -D_WIN32 -D__WINNT__ -D_X86_=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -D__i386 -D__WINNT -Asystem(winnt) -Acpu(i386) -Amachine(i386) -D__EXCEPTIONS -pedantic-errors -remap -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di586 -Dpentium -D__i586 -D__i586__ -D__pentium -D__pentium__ -D__CYGWIN32__ -D__CYGWIN__ vci.cc c:\tmp/ccEUbaaa.ii
GNU CPP version 2.95 19990728 (release) (80386, BSD syntax)
#include "..." search starts here:
#include <...> search starts here:
/Program/Cygnus/cygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95/../../../../../include/g++-3
/Program/Cygnus/cygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95/../../../../../include
/Program/Cygnus/cygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95/../../../../i586-cygwin32/include
/Program/Cygnus/cygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95/include
End of search list.
The following default directories have been omitted from the search path:
/usr/include
End of omitted list.
/Program/Cygnus/cygwin-b20/H-i586-cygwin32/bin/../lib/gcc-lib/i586-cygwin32/2.95/cc1plus.exe c:\tmp/ccEUbaaa.ii -quiet -dumpbase vci.cc -pedantic-errors -version -o c:\tmp/cc8Edaaa.s
GNU C++ version 2.95 19990728 (release) (i586-cygwin32) compiled by GNU C version 2.95 19990728 (release).
vci.cc: In method `void X<T>::init(const vector<T,allocator<_Tp1> > &)':
vci.cc:22: parse error before `='
vci.cc: In method `void X<basic_string<char,string_char_traits<char>,__default_alloc_template<false,0> > >::init(const vector<basic_string<char,string_char_traits<char>,__default_alloc_template<false,0> >,allocator<basic_string<char,string_char_traits<char>,__default_alloc_template<false,0> > > > &)':
vci.cc:39: instantiated from here
vci.cc:24: `src' undeclared (first use this function)
vci.cc:24: (Each undeclared identifier is reported only once
vci.cc:24: for each function it appears in.)
-----------------------------------------------------------------------------
Source. Sorry if it is so long, but I don't want to take the risk of
doing anything to make the iterator invalid. It's mostly pretty
trivial. As mentioned above, if Iter is a separate template, not part
of Wrapper, it compiles and works as expected.
-----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <iostream.h>
template< class T >
class X
{
public:
virtual void init( std::vector< T > const& other ) ;
T const* data() { return myData ; }
private:
T myData[ 5 ] ;
} ;
template< class T >
void
X< T >::init( std::vector< T > const& other )
{
assert( other.size() >= 5 ) ;
std::vector< T >::const_iterator
src = other.begin() ;
for ( int i = 0 ; i < 5 ; ++ i ) {
myData[ i ] = *src ++ ;
}
}
int
main()
{
std::vector< std::string >
v ;
v.push_back( "1" ) ;
v.push_back( "2" ) ;
v.push_back( "3" ) ;
v.push_back( "4" ) ;
v.push_back( "5" ) ;
X< std::string > x ;
x.init( v ) ;
return 0 ;
}
-----------------------------------------------------------------------------
--
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelhüttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627