This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++: Fail to find function (constructor)
- To: gcc-bugs at gcc dot gnu dot org
- Subject: g++: Fail to find function (constructor)
- From: Ulf Larsson <ulf dot larsson at mbox337 dot swipnet dot se>
- Date: Fri, 17 Mar 2000 06:46:25 +0100
Hi,
g++ don't accept this code which I think is correct (for example it
works if I replace std::string with char*).
mem_fun.cc
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
struct A
{
void foo (std::string const & ) {}
};
void
bar (std::string const & str)
{
std::vector<A*> v;
v.push_back (new A());
std::for_each (v.begin (), v.end (),
std::bind2nd (std::mem_fun (&A::foo), str));
}
I belive that it's the same bug as in
http://gcc.gnu.org/ml/gcc-bugs/2000-01/msg00657.html
The response I got was doubt about it being a bug, but I still think it
is. The problem seems to occure when you have three user defined types.
If there is some simple work-around, like extra parenthesis, I would be
glad to hear about them.
Ulf Larsson
/usr/local/egcs-ss/bin/g++ --verbose -c mem_fun.cc
Reading specs from
/usr/local/egcs-ss/lib/gcc-lib/i686-pc-linux-gnu/2.96/specs
gcc version 2.96 20000228 (experimental)
/usr/local/egcs-ss/lib/gcc-lib/i686-pc-linux-gnu/2.96/cpp -lang-c++ -v
-D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=96 -D__GNUC_PATCHLEVEL__=0
-D__cplusplus -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__
-D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Acpu(i386)
-Amachine(i386) -Di386 -D__i386 -D__i386__ -D__tune_pentiumpro__
mem_fun.cc /tmp/cc6ngkAX.ii
GNU CPP version 2.96 20000228 (experimental) (cpplib)
(i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/egcs-ss/include/g++-3
/usr/local/egcs-ss/include
/usr/local/egcs-ss/i686-pc-linux-gnu/include
/usr/local/egcs-ss/lib/gcc-lib/i686-pc-linux-gnu/2.96/include
/usr/include
End of search list.
/usr/local/egcs-ss/lib/gcc-lib/i686-pc-linux-gnu/2.96/cc1plus
/tmp/cc6ngkAX.ii -quiet -dumpbase mem_fun.cc -version -o /tmp/ccykT7HZ.s
GNU C++ version 2.96 20000228 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 2.95.1 19990816 (release).
/usr/local/egcs-ss/include/g++-3/stl_function.h: In instantiation of
`binder2nd<mem_fun1_t<void, A, const string &> >':
/usr/local/egcs-ss/include/g++-3/stl_function.h:231: instantiated from
`bind2nd (const _Operation &, const _Tp &) [with _Operation =
mem_fun1_t<void, A, const string &>, _Tp = basic_string<char,
string_char_traits<char>, __default_alloc_template<true, 0> >]'
mem_fun.cc:17: instantiated from here
/usr/local/egcs-ss/include/g++-3/stl_function.h:221: forming reference
to reference type `const string
/usr/local/egcs-ss/include/g++-3/stl_function.h:221: &const'
/usr/local/egcs-ss/include/g++-3/stl_function.h: In function
`binder2nd<_Operation> bind2nd (const
/usr/local/egcs-ss/include/g++-3/stl_function.h: _Operation &, const _Tp
&) [with _Operation =
/usr/local/egcs-ss/include/g++-3/stl_function.h: mem_fun1_t<void, A,
const string &>, _Tp =
/usr/local/egcs-ss/include/g++-3/stl_function.h: basic_string<char,
string_char_traits<char>,
/usr/local/egcs-ss/include/g++-3/stl_function.h:
__default_alloc_template<true, 0> >]':
mem_fun.cc:17: instantiated from here
/usr/local/egcs-ss/include/g++-3/stl_function.h:233: no matching
function for call to
/usr/local/egcs-ss/include/g++-3/stl_function.h:233:
`binder2nd<mem_fun1_t<void, A, const string &>
/usr/local/egcs-ss/include/g++-3/stl_function.h:233: >::binder2nd (const
mem_fun1_t<void, A, const
/usr/local/egcs-ss/include/g++-3/stl_function.h:233: string &> &, const
basic_string<char,
/usr/local/egcs-ss/include/g++-3/stl_function.h:233:
string_char_traits<char>,
/usr/local/egcs-ss/include/g++-3/stl_function.h:233:
__default_alloc_template<true, 0> > &)'
/usr/local/egcs-ss/include/g++-3/stl_function.h:214: candidates are:
binder2nd<mem_fun1_t<void, A,
/usr/local/egcs-ss/include/g++-3/stl_function.h:214: const string &>
>::binder2nd (const
/usr/local/egcs-ss/include/g++-3/stl_function.h:214:
binder2nd<mem_fun1_t<void, A, const string &> > &)