Solaris 2.5.1, gcc version 2.96 20000621; string operator not found
Jim McKelvey
mckelvey@bean.jpl.nasa.gov
Wed Jun 21 15:39:00 GMT 2000
C++ program below fails with unresolved + operator for strings. The compile
succeeds if EITHER the virtual is removed from method f OR the use of generic
parameter title is replaced with a call to static method name:
#include <string>
template <const string& title>
class X
{
public:
X(void);
virtual ~X(void);
virtual void f(void) const;
// void f(void) const;
static const string& name(void);
};
template <const string& title>
X<title>::
X<title>(void)
{
}
template <const string& title>
X<title>::
~X<title>(void)
{
}
template <const string& title>
void X<title>::
f(void) const
{
string x = title + ':';
// string x = name() + ':';
}
template <const string& title>
const string& X<title>::
name(void)
{
return title;
}
extern const string TITLE;
int main(void)
{
X<TITLE> x;
return 0;
}
mushroom...private>g++ -v -c test.cc
Reading specs from
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/lib/gcc-lib/sparc-sun-solaris2
.5.1/2.96/specs
gcc version 2.96 20000621 (experimental)
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/lib/gcc-lib/sparc-sun-solaris2
.5.1/2.96/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=96
-D__GNUC_PATCHLEVEL__=0 -D__cplusplus -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4
-D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix
-Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__ -Acpu(sparc)
-Amachine(sparc) test.cc /var/tmp/cc7JKAr5.ii
GNU CPP version 2.96 20000621 (experimental) (cpplib)
(sparc)
#include "..." search starts here:
#include <...> search starts here:
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/include/g++-3
/usr/local/include
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/lib/gcc-lib/sparc-sun-solaris2
.5.1/2.96/include
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/sparc-sun-solaris2.5.1/include
/usr/include
End of search list.
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/lib/gcc-lib/sparc-sun-solaris2
.5.1/2.96/cc1plus /var/tmp/cc7JKAr5.ii -quiet -dumpbase test.cc -version -o
/var/tmp/cc1KzzA7.s
GNU C++ version 2.96 20000621 (experimental) (sparc-sun-solaris2.5.1) compiled
by GNU C version 2.96 20000621 (experimental).
test.cc: In method `void X<title>::f () const [with const string &title
= TITLE]':
test.cc:60: instantiated from here
test.cc:43: invalid operands of types `const basic_string<char,
string_char_traits<char>, __default_alloc_template<false, 0> > &' and
`char' to binary `operator+'
mushroom...private>
More information about the Gcc-bugs
mailing list