public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Karel Gardas <kgardas@objectsecurity.com>
To: GCC Mailing List <gcc@gcc.gnu.org>
Subject: basic_string linking related problem.
Date: Wed, 09 Oct 2002 16:52:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.43.0210092122190.453-100000@thinkpad.c0202001.roe.itnq.net> (raw)


Hello,

one of third party libraries which we are using for our project suffers
from linking problems with some unresolved symbols. I've tracked it down
to following code:

//
//snacc_basic_string_problem.cc
//
//#include <string.h>

//#include <iostream>
//#include <stdlib.h>
//#include <stdio.h>  // maybe

#include <iostream>
//#include <string.h>

int
main()
{
    std::basic_string<unsigned char> bytes;
    for (unsigned char i=0; i<255; i++) {
	bytes += i;
    }
    long len = bytes.length();
    const unsigned char* data = bytes.data();
    std::cerr << "len: " << len << std::endl;
    std::cerr << "data: " << data << std::endl;
}

Please try to compile and link it. It compiles well here, but linker
complains with unresolved symbols:

thinkpad:~/mujprog/c-cc/tests/gcc321$ c++ snacc_basic_string_problem.cc
/tmp/ccRiR23T.o: In function `std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> >::replace(__gnu_cxx::__normal_iterator<unsigned char*, std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> > >, __gnu_cxx::__normal_iterator<unsigned char*, std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> > >, unsigned, unsigned char)':
/tmp/ccRiR23T.o(.gnu.linkonce.t._ZNSbIhSt11char_traitsIhESaIhEE7replaceEN9__gnu_cxx17__normal_iteratorIPhS2_EES6_jh+0xc3): undefined reference to `std::char_traits<unsigned char>::assign(unsigned char*, unsigned, unsigned char)'
/tmp/ccRiR23T.o: In function `std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> >::_Rep::_M_clone(std::allocator<unsigned char> const&, unsigned)':
/tmp/ccRiR23T.o(.gnu.linkonce.t._ZNSbIhSt11char_traitsIhESaIhEE4_Rep8_M_cloneERKS1_j+0xb1): undefined reference to `std::char_traits<unsigned char>::copy(unsigned char*, unsigned char const*, unsigned)'
/tmp/ccRiR23T.o: In function `std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> >::_M_mutate(unsigned, unsigned, unsigned)':
/tmp/ccRiR23T.o(.gnu.linkonce.t._ZNSbIhSt11char_traitsIhESaIhEE9_M_mutateEjjj+0x13b): undefined reference to `std::char_traits<unsigned char>::copy(unsigned char*, unsigned char const*, unsigned)'
/tmp/ccRiR23T.o(.gnu.linkonce.t._ZNSbIhSt11char_traitsIhESaIhEE9_M_mutateEjjj+0x16c): undefined reference to `std::char_traits<unsigned char>::copy(unsigned char*, unsigned char const*, unsigned)'
/tmp/ccRiR23T.o(.gnu.linkonce.t._ZNSbIhSt11char_traitsIhESaIhEE9_M_mutateEjjj+0x274): undefined reference to `std::char_traits<unsigned char>::move(unsigned char*, unsigned char const*, unsigned)'
collect2: ld returned 1 exit status
You have mail in /var/mail/karel
thinkpad:~/mujprog/c-cc/tests/gcc321$


I don't know if it's legal to use basic_string in user code. If it is,
then it's a bug somewhere and I'll submit it into GNATS. What I need and
main reason for asking here is: is the code above legal?

Compiler used is:

thinkpad:~/mujprog/c-cc/tests/gcc321$ c++ -v
Reading specs from
/home/karel/usr/local/gcc3.2.x/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/specs
Configured with: /home/karel/cvs/gcc/gcc3.2/configure
--prefix=/home/karel/usr/local/gcc3.2.x --enable-shared --enable-threads
--enable-languages=c++ --program-prefix=a --enable-__cxa_atexit
Thread model: posix
gcc version 3.2.1 20021007 (prerelease)
thinkpad:~/mujprog/c-cc/tests/gcc321$

I've got these errors with using gcc3.2 too:

thinkpad:~/usr/src/getronics/SNACC/c++-lib/src$ c++ -v
Reading specs from
/home/karel/usr/local/gcc3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs
Configured with: ../../gcc3.2/configure
--prefix=/home/karel/usr/local/gcc3.2 --enable-languages=c++,objc
--program-prefix=a --enable-__cxa_atexit
Thread model: posix
gcc version 3.2
thinkpad:~/usr/src/getronics/SNACC/c++-lib/src$


The interesting is that this program compiles/links well with using gcc
3.1.1 - so from this point of view - this is a regression in gcc3.2/3.2.1

thinkpad:~/mujprog/c-cc/tests/gcc321$ c++ -v
Reading specs from
/home/karel/usr/local/gcc3.1.1cxa_atexit/lib/gcc-lib/i686-pc-linux-gnu/3.1.1/specs
Configured with: /home/karel/cvs/gcc/gcc3.1/configure
--prefix=/home/karel/usr/local/gcc3.1.1cxa_atexit --enable-shared
--enable-threads --enable-languages=c++ --program-prefix=a
--enable-__cxa_atexit
Thread model: posix
gcc version 3.1.1
thinkpad:~/mujprog/c-cc/tests/gcc321$ c++ snacc_basic_string_problem.cc
thinkpad:~/mujprog/c-cc/tests/gcc321$ ./a.out
len: 255
data:
thinkpad:~/mujprog/c-cc/tests/gcc321$
thinkpad:~/mujprog/c-cc/tests/gcc321$


I'm waiting for confirmation that this is really bug, and then I'll submit
it into gnats.

Thanks a lot,

Karel
--
Karel Gardas                  kgardas@objectsecurity.com
ObjectSecurity Ltd.           http://www.objectsecurity.com


             reply	other threads:[~2002-10-09 19:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-09 16:52 Karel Gardas [this message]
2002-10-09 19:49 Benjamin Kosnik
2002-10-10  8:10 ` Karel Gardas

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=Pine.LNX.4.43.0210092122190.453-100000@thinkpad.c0202001.roe.itnq.net \
    --to=kgardas@objectsecurity.com \
    --cc=gcc@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).