This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/19170] New: Compilation error at a vector definition
- From: "rjimenez at ujaen dot es" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Dec 2004 19:43:03 -0000
- Subject: [Bug c++/19170] New: Compilation error at a vector definition
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hi,
The compiler (g++ 3.4.2) gives me an error when i write:
B b;
vector<A>elemA(2, b);
B can be, for instance, a pointer to an integer, or a class. A is defined as:
class A{
public:
A(B b) {}
private:
A(const A&){} //!< disallow copying
A& operator=(const A&){ return const_cast<A&>(*this);} //!< disallow copying
};
The strange thing is that the constructor i am invoking is the public one not
the private. The compilation is fine when B is an integer.
The message of the compiler is:
g++ -g -Wall -c main.cc -o main.o
main.cc: In function `void std::_Construct(_T1*, const _T2&) [with _T1 = A, _T2
= A]':
/usr/lib/gcc/x86_64-redhat-linux/3.4.2/../../../../include/c++/3.4.2/bits/stl_uninitialized.h:194:
instantiated from `_ForwardIterator
std::__uninitialized_fill_n_aux(_ForwardIterator, _Size, const _Tp&,
__false_type) [with _ForwardIterator = A*, _Size = long unsigned int, _Tp = A]'
/usr/lib/gcc/x86_64-redhat-linux/3.4.2/../../../../include/c++/3.4.2/bits/stl_uninitialized.h:219:
instantiated from `_ForwardIterator
std::uninitialized_fill_n(_ForwardIterator, _Size, const _Tp&) [with
_ForwardIterator = A*, _Size = long unsigned int, _Tp = A]'
/usr/lib/gcc/x86_64-redhat-linux/3.4.2/../../../../include/c++/3.4.2/bits/stl_vector.h:194:
instantiated from `std::vector<_Tp, _Alloc>::vector(size_t, const _Tp&, const
typename std::_Vector_base<_Tp, _Alloc>::allocator_type&) [with _Tp = A, _Alloc
= std::allocator<A>]'
main.cc:33: instantiated from here
main.cc:21: error: `A::A(const A&)' is private
/usr/lib/gcc/x86_64-redhat-linux/3.4.2/../../../../include/c++/3.4.2/bits/stl_construct.h:81:
error: within this context
make: *** [main.o] Error 1
Thanks in advance.
Roberto.
--
Summary: Compilation error at a vector definition
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rjimenez at ujaen dot es
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: x86-64
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19170