From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25149 invoked by alias); 8 Oct 2002 22:46:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 25118 invoked by uid 71); 8 Oct 2002 22:46:02 -0000 Resent-Date: 8 Oct 2002 22:46:02 -0000 Resent-Message-ID: <20021008224602.25117.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, gunneyb@llnl.gov Received: (qmail 24709 invoked from network); 8 Oct 2002 22:43:57 -0000 Received: from unknown (HELO tux75.llnl.gov) (134.9.17.56) by sources.redhat.com with SMTP; 8 Oct 2002 22:43:57 -0000 Received: (from gunney@localhost) by tux75.llnl.gov (8.11.6/8.11.6) id g98Mhui17096; Tue, 8 Oct 2002 15:43:56 -0700 Message-Id: <200210082243.g98Mhui17096@tux75.llnl.gov> Date: Tue, 08 Oct 2002 15:46:00 -0000 From: gunneyb@llnl.gov Reply-To: gunneyb@llnl.gov To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: 3.113 Subject: c++/8172: no operator+ for string in library X-SW-Source: 2002-10/txt/msg00314.txt.bz2 List-Id: >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, std::allocator > std::operator+, std::allocator >(std::basic_string, std::allocator > const&, std::basic_string, std::allocator > const&)' collect2: ld returned 1 exit status >How-To-Repeat: Program text: #include #include 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: