public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16875] New: Fails to compile: STL container of const pointer to X
@ 2004-08-04 12:41 loose at astron dot nl
  2004-08-04 12:46 ` [Bug c++/16875] " loose at astron dot nl
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: loose at astron dot nl @ 2004-08-04 12:41 UTC (permalink / raw)
  To: gcc-bugs

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<X* 
const>':
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<X* const>]'
/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<X* const>]'
/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<X* const>]'
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 <list>

struct X
{
};

int main()
{
  std::list<X* const> 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


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

end of thread, other threads:[~2004-10-07  7:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-04 12:41 [Bug c++/16875] New: Fails to compile: STL container of const pointer to X loose at astron dot nl
2004-08-04 12:46 ` [Bug c++/16875] " loose at astron dot nl
2004-08-05  2:07 ` [Bug libstdc++/16875] " pinskia at gcc dot gnu dot org
2004-08-05  8:03 ` gdr at integrable-solutions dot net
2004-10-06 20:08 ` pinskia at gcc dot gnu dot org
2004-10-06 20:32 ` pinskia at gcc dot gnu dot org
2004-10-06 22:04 ` igodard at pacbell dot net
2004-10-07  1:23 ` pinskia at gcc dot gnu dot org
2004-10-07  2:22 ` igodard at pacbell dot net
2004-10-07  2:50 ` pinskia at gcc dot gnu dot org
2004-10-07  7:32 ` loose at astron dot nl

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