From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7632 invoked by alias); 4 Aug 2004 12:41:28 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 7623 invoked by uid 48); 4 Aug 2004 12:41:27 -0000 Date: Wed, 04 Aug 2004 12:41:00 -0000 From: "loose at astron dot nl" To: gcc-bugs@gcc.gnu.org Message-ID: <20040804124119.16875.loose@astron.nl> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/16875] New: Fails to compile: STL container of const pointer to X X-Bugzilla-Reason: CC X-SW-Source: 2004-08/txt/msg00317.txt.bz2 List-Id: The IMHO valid C++ code in the sample program tt.cc (see below) fails to compile. I've tried using different STL containers, but the result was (more or less) the same. I've tried to compile this code with three different versions of gcc (3.2.1, 3.2.2, and 3.4.1), and all three fail. Furthermore, I've tried to compile it with the Intel C++ compiler (v8.0) which accepts the code. $ g++ -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man -- infodir=/usr/share/info --enable-shared --enable-threads=posix --disable- checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) $ g++ -save-temps tt.cc /usr/include/c++/3.2.2/bits/stl_alloc.h: In instantiation of `std::allocator': tt.cc:9: instantiated from here /usr/include/c++/3.2.2/bits/stl_alloc.h:674: `const _Tp* std::allocator<_Alloc>::address(const _Tp&) const [with _Tp = X* const]' and `_Tp* std::allocator<_Alloc>::address(_Tp&) const [with _Tp = X* const]' cannot be overloaded /usr/include/c++/3.2.2/bits/stl_construct.h: In function `void std::_Construct(_T1*, const _T2&) [with _T1 = X* const, _T2 = X*]': /usr/include/c++/3.2.2/bits/stl_list.h:328: instantiated from `std::_List_node<_Tp>* std::list<_Tp, _Alloc>::_M_create_node(const _Tp&) [with _Tp = X* const, _Alloc = std::allocator]' /usr/include/c++/3.2.2/bits/stl_list.h:430: instantiated from `std::_List_iterator<_Tp, _Tp&, _Tp*> std::list<_Tp, _Alloc>::insert (std::_List_iterator<_Tp, _Tp&, _Tp*>, const _Tp&) [with _Tp = X* const, _Alloc = std::allocator]' /usr/include/c++/3.2.2/bits/stl_list.h:479: instantiated from `void std::list<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = X* const, _Alloc = std::allocator]' tt.cc:10: instantiated from here /usr/include/c++/3.2.2/bits/stl_construct.h:78: static_cast from type `X* const*' to type `void*' casts away constness $ cat tt.cc #include struct X { }; int main() { std::list li; li.push_back(new X()); } -- Summary: Fails to compile: STL container of const pointer to X Product: gcc Version: 3.4.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: loose at astron dot nl CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16875