This is the mail archive of the gcc-prs@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]
Other format: [Raw text]

c++/4980: -pedantic leads to parse error at strange place<synopsis of the problem (one line)>



>Number:         4980
>Category:       c++
>Synopsis:       -pedantic leads to parse error at strange place
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 01 11:46:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Alexander Buerger
>Release:        3.0.2 (Debian) (Debian testing/unstable)
>Organization:
>Environment:
System: Linux feynman 2.4.16 #1 Fre Nov 30 13:25:13 CET 2001 i586 unknown
Architecture: i586

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Description:

G++ fails to parse the first line in the `delete_elements' method (below),
but only with `-pedantic' switched on.

	
>How-To-Repeat:

Compilation of the following source
------------------
#include <vector>

template<typename C>
void delete_elements( std::vector< C* >& vec ) 
{
    std::vector< C* >::iterator it=vec.begin(); // FIXME: -pedantic does not like this; why???
    while( it!=vec.end() )
        delete *it++;
}

int main( int, char*[] )
{
    std::vector<int*> v;
    delete_elements( v );

    return 0;
}
------------------
with `gcc-3.0 -v -pedantic -o test test.cpp'
leads to this output (on my machine):
------------------
Reading specs from /usr/lib/gcc-lib/i386-linux/3.0.2/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.0.2 (Debian)
 /usr/lib/gcc-lib/i386-linux/3.0.2/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=2 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -pedantic -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ test.cpp -D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase test.cpp -pedantic -version -o /tmp/cc27ERkQ.s
 GNU CPP version 3.0.2 (Debian) (cpplib) (i386 Linux/ELF)
 GNU C++ version 3.0.2 (Debian) (i386-linux)
         compiled by GNU C version 3.0.2 (Debian).
 ignoring nonexistent directory "/usr/i386-linux/include"
 #include "..." search starts here:
 #include <...> search starts here:
  /usr/include/g++-v3
  /usr/include/g++-v3/i386-linux
  /usr/include/g++-v3/backward
  /usr/local/include
  /usr/lib/gcc-lib/i386-linux/3.0.2/include
  /usr/include
End of search list.
test.cpp: In function `void delete_elements(std::vector<C*, std::allocator<C*> 
  >&)':
test.cpp:112: parse error before `=' token
test.cpp: In function `void delete_elements(std::vector<C*, std::allocator<C*> 
  >&) [with C = int]':
test.cpp:120:   instantiated from here
test.cpp:113: `it' undeclared (first use this function)
test.cpp:113: (Each undeclared identifier is reported only once for each 
  function it appears in.)
------------------
The problem does not appear without `-pedantic'.

	
>Fix:

Work-around: omit `-pedantic'.
	
>Release-Note:
>Audit-Trail:
>Unformatted:


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