public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/3402: GCC 3.0 does not compile using push_back function on a vector of pairs of const strings
@ 2001-06-26  1:06 Artem Khodush
  0 siblings, 0 replies; 3+ messages in thread
From: Artem Khodush @ 2001-06-26  1:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: "Artem Khodush" <artem@duma.gov.ru>
To: <roy@haematic.org>
Cc: <gcc-gnats@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>
Subject: Re: c++/3402: GCC 3.0 does not compile using push_back function on a vector of pairs of const strings
Date: Tue, 26 Jun 2001 11:48:49 +0400

 > GCC 3.0 does not compile using push_back function on a vector of pairs of const strings
 
 GCC 3.0 is right, the c++ standard states it pretty clear: anything const 
 can not be stored in any kind of standard containers.
 
   23.1  Container requirements              
 ...
 3 The  type of objects stored in these components must meet the require-
   ments of CopyConstructible types  (_lib.copyconstructible_),  and  the
   additional requirements of Assignable types.
 
 4 In  Table  2,  T is the type used to instantiate the container, t is a
   value of T, and u is a value of (possibly const) T.
 
                      Table 2--Assignable requirements
 
 
             +------------------------------------------------+
             |expression   return type      post-condition    |
             +------------------------------------------------+
             |t = u        T&            t is equivalent to u |
             +------------------------------------------------+
 
 
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/3402: GCC 3.0 does not compile using push_back function on a vector of pairs of const strings
@ 2001-06-26  5:25 lerdsuwa
  0 siblings, 0 replies; 3+ messages in thread
From: lerdsuwa @ 2001-06-26  5:25 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, roy

Synopsis: GCC 3.0 does not compile using push_back function on a vector of pairs of const strings

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Tue Jun 26 05:25:03 2001
State-Changed-Why:
    Not a bug.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3402&database=gcc


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c++/3402: GCC 3.0 does not compile using push_back function on a vector of pairs of const strings
@ 2001-06-25  5:06 roy
  0 siblings, 0 replies; 3+ messages in thread
From: roy @ 2001-06-25  5:06 UTC (permalink / raw)
  To: gcc-gnats

>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<const std::string, const std::string>& std::pair<const 
   std::string, const std::string>::operator=(const std::pair<const 
   std::string, const std::string>&)':
/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<const std::string, const std::string>, _Alloc = std::allocator<std::pair<const std::string, const std::string> >]'
/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<const std::string, const std::string>, _Alloc = std::allocator<std::pair<const std::string, const std::string> >]'
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<const std::string, const std::string>::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<const std::string, const std::string>::second', 
   can't use default assignment operator




>How-To-Repeat:
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main(void)
{

  vector<pair<const string,const string> > ex;
  ex.push_back ( pair<const string,const string> ( "pair1.1", "pair1.2" ) );
  ex.push_back ( pair<const string,const string> ( "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:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-06-26  5:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-26  1:06 c++/3402: GCC 3.0 does not compile using push_back function on a vector of pairs of const strings Artem Khodush
  -- strict thread matches above, loose matches on Subject: below --
2001-06-26  5:25 lerdsuwa
2001-06-25  5:06 roy

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).