public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Bradford Castalia <Castalia@azstarnet.com>
To: ljrittle@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: c++/7708: g++ -O inserts definition of std::string::replace in  library module
Date: Tue, 14 Jan 2003 00:46:00 -0000	[thread overview]
Message-ID: <20030114004602.25748.qmail@sources.redhat.com> (raw)

The following reply was made to PR c++/7708; it has been noted by GNATS.

From: Bradford Castalia <Castalia@azstarnet.com>
To: bangerth@dealii.org, Castalia@azstarnet.com, gcc-bugs@gcc.gnu.org,
   gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/7708: g++ -O inserts definition of std::string::replace in 
 library module
Date: Mon, 13 Jan 2003 17:36:47 -0700

 I've just installed the gcc32 package from the FreePSG ports site:
 
 idaeim:castalia>> g++ --version
 g++ (GCC) 3.2.1
 
 After running the test cases, as well as the full recompile of my project code,
 I can confirm that the -O switch no longer generates library symbol definitions
 for the std::string::replace method.
 
 Using a Test.h file:
 
 #include        <string>
 
 class Test
 {
 public:
 Test (const std::string& message = "");
 void message (const std::string& message);
 
 private:
 std::string Message;
 };
 
 And a Test.cpp file:
 
 #include        "Test.h"
 
 Test::Test (const std::string& message) : Message (message)
 {
 if (! Message.empty () && Message[Message.size () - 1] == '\n')
         Message.erase (Message.size () - 1);
 }
 
 void Test::message (const std::string& new_message)
 {
 Message.replace (std::string::size_type(0), Message.length (), new_message);
 if (! Message.empty () && Message[Message.size () - 1] == '\n')
         Message.erase (Message.size () - 1);
 }
 
 Building an object module compiled with g++ 3.1.1 20020617 (prerelease) [FreeBSD]
 (g++31 -O -c -o opt-Test.o Test.cpp) and then examing the object symbols reveals,
 in addition to the weak symbols, a text symbol for "replace":
 
 idaeim:castalia>> nm -g -o -C opt-Test.o | grep replace
 opt-Test.o:00000000 W std::string& std::string::_M_replace<char const*>(__gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>, char const*, char const*, std::input_iterator_tag)
 opt-Test.o:00000000 W std::string& std::string::_M_replace_safe<__gnu_cxx::__normal_iterator<char*, std::string> >(__gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>)
 opt-Test.o:00000000 W std::string& std::string::_M_replace_safe<char const*>(__gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>, char const*, char const*)
 opt-Test.o:000001f0 T std::string::replace(unsigned, unsigned, char const*, unsigned)
 
 Building an object module compiled with g++ 3.2.1 and then examing the symbols
 reveals that the text symbol is now an undefined reference to "replace" as expected:
 
 idaeim:castalia>> nm -g -o -C new-opt-Test.o | grep replace
 new-opt-Test.o:00000000 W std::string& std::string::_M_replace<char const*>(__gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>, char const*, char const*, std::input_iterator_tag)
 new-opt-Test.o:00000000 W std::string& std::string::_M_replace_safe<__gnu_cxx::__normal_iterator<char*, std::string> >(__gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>)
 new-opt-Test.o:00000000 W std::string& std::string::_M_replace_safe<char const*>(__gnu_cxx::__normal_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::string>, char const*, char const*)
 new-opt-Test.o:         U std::string::replace(unsigned, unsigned, char const*, unsigned)
 
 The problem of problem of multiple definitions at link time has now been fixed.
 
 Thnx!
 
 -- 
 
 Bradford Castalia
 Systems Analyst
 
 
 bangerth@dealii.org wrote:
 > 
 > Synopsis: g++ -O inserts definition of std::string::replace in library module
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: bangerth
 > State-Changed-When: Thu Dec 19 18:19:52 2002
 > State-Changed-Why:
 >     I tried your program with gcc3.2, but on x86 linux. I can
 >     confirm that the mentioned symbols are present in the
 >     object file. However, they are weak:
 >     00000000 W std::string& std::string::_M_replace<....
 > 
 >     Weak symbols means: they can be in multiple object files,
 >     and one of these copies is picked at link time.
 > 
 >     Could you possibly check whether the problem still exists
 >     on your platform with gcc3.2.1?
 > 
 >     Thanks
 >       Wolfgang
 > 
 > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7708
 
 Wolfgang Bangerth wrote:
 > 
 > On Sun, 22 Dec 2002, Bradford Castalia wrote:
 > 
 > > When I get gcc3.2.1 (or greater) installed on the FreeBSD workstation
 > > (hasn't happened yet, sorry) I will definately run the test files
 > > again. You will probably get a faster response from one of the FreeBSD
 > > developers (http://www.FreeBSD.org).
 > 
 > Please let us know about your results. Maybe someone of the FeeBSD
 > maintainers could also try to look into this?
 > 
 > Regards
 >   Wolfgang
 > 
 > -------------------------------------------------------------------------
 > Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
 >                                www: http://www.ticam.utexas.edu/~bangerth


             reply	other threads:[~2003-01-14  0:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-14  0:46 Bradford Castalia [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-01-14  0:46 Wolfgang Bangerth
2002-12-22 20:46 Bradford Castalia
2002-12-19 18:19 bangerth

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=20030114004602.25748.qmail@sources.redhat.com \
    --to=castalia@azstarnet.com \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=ljrittle@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: link
Be 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).