public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Castalia@azstarnet.com To: gcc-gnats@gcc.gnu.org Subject: optimization/7708: g++ -O inserts definition of std::string::replace in library module Date: Fri, 23 Aug 2002 18:26:00 -0000 [thread overview] Message-ID: <20020824010447.25540.qmail@sources.redhat.com> (raw) >Number: 7708 >Category: optimization >Synopsis: g++ -O inserts definition of std::string::replace in library module >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Aug 23 18:06:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Bradford Castalia >Release: gcc version 3.1.1 20020617 (prerelease) [FreeBSD] >Organization: >Environment: FreeBSD idaeim 4.6-STABLE FreeBSD 4.6-STABLE #0: Mon Aug 5 19:42:48 MST 2002 Configured with: ./..//gcc-20020617/configure --disable-nls --with-gnu-as --with-gnu-ld --with-gxx-include-dir=/usr/local/lib/gcc-lib/i386-portbld-freebsd4.6/3.1.1/include/g++ --disable-libgcj --disable-shared --prefix=/usr/local i386-portbld-freebsd4.6 Thread model: posix >Description: Use of -O with g++ when compiling a class that uses the std::string methods replace and/or erase generates a definition of the replace method in the object file. When the object file is used as a library module this results in multiple definition error at link time when the problem has occured in more than one module. >How-To-Repeat: Separate the attached file into Test.h, Test.cpp, and Makefile files. Use gmake with the Makefile to compile the object module and place it in the library; or just compile the object file with "g++ -O -c -o Test.o Test.cpp". Examine the results with nm. Notice the definition of the std::string::replace method in the object file. Recompile without the -O option. Notice that the definition of the std::string::replace method is no longer present in the nm report of the object file. >Fix: A) Don't use optimization (sigh). B) Note this "side effect" of optimization in the docs. C) Prevent optimization from generating method definitions not defined by the user code itself. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="Test" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Test" VGVzdC5oIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0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TElCUkFSWSAgPSBsaWJUZXN0LmEKCiMgU291cmNl IGZpbGVzOgoKU09VUkNFUyAgPSBUZXN0LmNwcApPQkpFQ1RTICA9ICQoU09VUkNFUzolLmNwcD0l Lm8pCgojIFJlbW92ZSB0aGUgZm9sbG93aW5nIGxpbmUgdG8gZWxpbWluYXRlIHRoZSBkZWZpbml0 aW9uIG9mICJyZXBsYWNlIi4KQ1hYRkxBR1MgPSAtTwoKJChMSUJSQVJZKToJCSQoTElCUkFSWSko JChPQkpFQ1RTKSkKCg==
reply other threads:[~2002-08-24 1:06 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020824010447.25540.qmail@sources.redhat.com \ --to=castalia@azstarnet.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).