From mboxrd@z Thu Jan 1 00:00:00 1970 From: roy@haematic.org To: gcc-gnats@gcc.gnu.org Subject: c++/3402: GCC 3.0 does not compile using push_back function on a vector of pairs of const strings Date: Mon, 25 Jun 2001 05:06:00 -0000 Message-id: <20010625120143.21912.qmail@sourceware.cygnus.com> X-SW-Source: 2001-06/msg01038.html List-Id: >Number: 3402 >Category: c++ >Synopsis: GCC 3.0 does not compile using push_back function on a vector of pairs of const strings >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Jun 25 05:06:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: roy@haematic.org >Release: gcc version 3.0 >Organization: >Environment: solaris 2.7 (Generic_106541-16 sun4u sparc SUNW,Ultra-Enterprise-10000) >Description: Compiling a simple program using a vector of pairs on const strings causes g++ to fail with the following message; c++test> g++ -v stltest1.cpp -save-temps -o stltest1 Reading specs from /work/gcc30/local/lib/gcc-lib/sparc-sun-solaris2.7/3.0/specs Configured with: ../src/gcc-3.0/configure --prefix=/work/gcc30/local --enable-threads=posix --enable-shared --enable-languages=c++ --with-gnu-ld --with-ld=/work/gcc30/local/bin/ld --with-gnu-as --with-as=/work/gcc30/local/bin/as Thread model: posix gcc version 3.0 /work/gcc30/local/lib/gcc-lib/sparc-sun-solaris2.7/3.0/cpp0 -lang-c++ -D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem=unix -Asystem=svr4 -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_XOPEN_SOURCE=500 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D__EXTENSIONS__ -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc stltest1.cpp stltest1.ii GNU CPP version 3.0 (cpplib) (sparc) ignoring nonexistent directory "/work/gcc30/local/sparc-sun-solaris2.7/include" #include "..." search starts here: #include <...> search starts here: /work/gcc30/local/include/g++-v3 /work/gcc30/local/include/g++-v3/sparc-sun-solaris2.7 /work/gcc30/local/include/g++-v3/backward /usr/local/include /work/gcc30/local/lib/gcc-lib/sparc-sun-solaris2.7/3.0/include /usr/include End of search list. /work/gcc30/local/lib/gcc-lib/sparc-sun-solaris2.7/3.0/cc1plus -fpreprocessed stltest1.ii -quiet -dumpbase stltest1.cpp -version -o stltest1.s GNU CPP version 3.0 (cpplib) (sparc) GNU C++ version 3.0 (sparc-sun-solaris2.7) compiled by GNU C version 3.0. /work/gcc30/local/include/g++-v3/bits/stl_vector.h: In member function `std::pair& std::pair::operator=(const std::pair&)': /work/gcc30/local/include/g++-v3/bits/stl_vector.h:552: instantiated from `void std::vector<_Tp, _Alloc>::_M_insert_aux(std::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = std::pair, _Alloc = std::allocator >]' /work/gcc30/local/include/g++-v3/bits/stl_vector.h:285: instantiated from `void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = std::pair, _Alloc = std::allocator >]' stltest1.cpp:11: instantiated from here /work/gcc30/local/include/g++-v3/bits/stl_vector.h:552: non-static const member `const std::string std::pair::first', can't use default assignment operator /work/gcc30/local/include/g++-v3/bits/stl_vector.h:552: non-static const member `const std::string std::pair::second', can't use default assignment operator >How-To-Repeat: #include #include #include using namespace std; int main(void) { vector > ex; ex.push_back ( pair ( "pair1.1", "pair1.2" ) ); ex.push_back ( pair ( "pair2.1", "pair2.2" ) ); } >Fix: Using "string" instead of "const string" works correctly, hence a work around is to not use const. >Release-Note: >Audit-Trail: >Unformatted: