This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/11638] New: [3.3.1 prerelease] std::vector assign problem with null pointer constant
- From: "nick at ilm dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jul 2003 23:19:14 -0000
- Subject: [Bug libstdc++/11638] New: [3.3.1 prerelease] std::vector assign problem with null pointer constant
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11638
Summary: [3.3.1 prerelease] std::vector assign problem with null
pointer constant
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nick at ilm dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-redhat-linux
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
The following code fails to compile with the prerelease:
----
#include <vector>
class A;
void
f()
{
std::vector<A *> v;
v.assign(5,0);
}
---
> /dept/rnd/vendor/gcc-3.3.1-20030720/bin/g++ -c testassign.C -o /dev/null
/dept/rnd/vendor/gcc-3.3.1-20030720/include/c++/3.3.1/bits/stl_vector.h: In
member function `void std::vector<_Tp, _Alloc>::_M_assign_dispatch(_Integer,
_Integer, __true_type) [with _Integer = int, _Tp = A*, _Alloc =
std::allocator<A*>]':
/dept/rnd/vendor/gcc-3.3.1-20030720/include/c++/3.3.1/bits/stl_vector.h:342:
instantiated from `void std::vector<_Tp, _Alloc>::assign(_InputIterator,
_InputIterator) [with _InputIterator = int, _Tp = A*, _Alloc = std::allocator<A*>]'
testassign.C:9: instantiated from here
/dept/rnd/vendor/gcc-3.3.1-20030720/include/c++/3.3.1/bits/stl_vector.h:841:
error: invalid
static_cast from type `int' to type `A*'
The following code:
----
class A;
void
f()
{
A *a = static_cast<A *>(0);
}
----
compiles correctly, so it looks like information's getting lost somewhere
in the templating. static_casting from 1 correctly returns the same error
as above.
This works with 3.2.3 but not 3.3 or the 3.3.1 prerelease.
-nick