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]
Other format: [Raw text]

[Bug c++/17166] New: g++ 3.4.1 and 3.5 forget a template function definition


When compiling the help.cpp file from Wesnoth CVS, both g++ 3.4.1 and 3.5 aren't
able to compile the following line. Previous versions of GCC and other compilers
don't have any problem with it.

show_info_about.erase(std::remove(show_info_about.begin(),
show_info_about.end(), gamemap::VOID_TERRAIN), show_info_about.end());

Here g++ seems to believe that the function std::remove is remove(const char *)
(file removal of the standard library). It doesn't see the stl_algo.h function.

help.cpp: In function `std::vector<help::topic, std::allocator<help::topic> >
help::generate_terrains_topics()':
help.cpp:849: error: cannot convert `__gnu_cxx::__normal_iterator<char*,
std::vector<char, std::allocator<char> > >' to `const char*' for argument `1' to
`int remove(const char*)'

However, the funny thing is that if I add the following lines just before, g++
compiles just fine the file.

typedef __typeof__ show_info_about.begin() iterator;
typedef __typeof__ gamemap::VOID_TERRAIN element;
iterator (*f)(iterator, iterator, element const &) = std::remove< iterator,
element >;

Please note that I don't use f afterwards. They really are dummy lines, f is
only here to verify that the remove function exists. And now g++ has suddenly
remembered that there is a std::remove with three arguments and it is now able
to find it at the next line.

$ LANG=C g++-3.4 -v
Reading specs from /usr/lib/gcc/i486-linux/3.4.1/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4
--enable-shared --with-system-zlib --enable-nls --without-included-gettext
--program-suffix=-3.4 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt
--enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm
--enable-java-awt=gtk --disable-werror i486-linux
Thread model: posix
gcc version 3.4.1 (Debian 3.4.1-7)

$ g++-3.5 -v
Reading specs from /usr/lib/gcc/i486-linux/3.5.0/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc
--prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.5
--enable-shared --with-system-zlib --enable-nls --enable-threads=posix
--without-included-gettext --program-suffix=-3.5 --enable-__cxa_atexit
--enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug
--enable-java-gc=boehm --enable-java-awt=gtk i486-linux
Thread model: posix
gcc version 3.5.0 20040724 (experimental) (Debian 3.5-0pre1)

$ g++-3.5 -c bug.ii
help.cpp: In function `std::vector<help::topic, std::allocator<help::topic> >
help::generate_terrains_topics()':
help.cpp:849: error: cannot convert `__gnu_cxx::__normal_iterator<char*,
std::vector<char, std::allocator<char> > >' to `const char*' for argument `1' to
`int remove(const char*)'
help.cpp:851: error: cannot convert `__gnu_cxx::__normal_iterator<char*,
std::vector<char, std::allocator<char> > >' to `const char*' for argument `1' to
`int remove(const char*)'

Sorry for the huge test-case. I may try to reduce it later. Since it is that
big, I don't provide the modified file with the three dummy lines. However I
have verified that adding them to line 48553 of the preprocessed file is enough
for g++ 3.4.1 and 3.5 to compile the file successfuly.

-- 
           Summary: g++ 3.4.1 and 3.5 forget a template function definition
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: guillaume dot melquiond at ens-lyon dot fr
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17166


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