public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/8172: no operator+ for string in library
@ 2002-10-08 15:46 gunneyb
0 siblings, 0 replies; only message in thread
From: gunneyb @ 2002-10-08 15:46 UTC (permalink / raw)
To: gcc-gnats
>Number: 8172
>Category: c++
>Synopsis: undefined reference to operator+ for string
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Oct 08 15:46:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Brian T. N. Gunney
>Release: 3.2
>Organization:
Lawrence Livermore National Lab
>Environment:
System: Linux tux75.llnl.gov 2.4.9-31smp #1 SMP Tue Feb 26 06:55:00 EST 2002 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.2/configure --prefix=/usr/apps/gcc/3.2
>Description:
The operator+ for string is missing when compiled with -fno-implicit-template.
The error occurs at link time as follows:
> /usr/apps/gcc/3.2/bin/g++ -o noplus noplus.o
noplus.o: In function `main':
noplus.o(.text+0xd8): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: ld returned 1 exit status
>How-To-Repeat:
Program text:
#include <string>
#include <iostream>
using namespace std;
int main() {
string s1 = "first";
string s2 = "second";
string s3, s4;
// This will not link.
s3 = s1 + s2;
// This works.
s4 = s1;
s4 += s2;
cout << "s1 = " << s1 << endl;
cout << "s2 = " << s2 << endl;
cout << "s3 = " << s3 << endl;
cout << "s4 = " << s4 << endl;
return 0;
}
Compile command:
g++ -fno-implicit-templates noplus.cc
>Fix:
Replace s3 = s1 + s2;
With s3 = s1; s3 += s3;
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-10-08 22:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-08 15:46 c++/8172: no operator+ for string in library gunneyb
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).