From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29092 invoked by alias); 27 Dec 2004 19:28:27 -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 29080 invoked by uid 48); 27 Dec 2004 19:28:24 -0000 Date: Mon, 27 Dec 2004 19:28:00 -0000 From: "rjimenez at ujaen dot es" To: gcc-bugs@gcc.gnu.org Message-ID: <20041227192823.19169.rjimenez@ujaen.es> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/19169] New: Compilation error at a vector definition X-Bugzilla-Reason: CC X-SW-Source: 2004-12/txt/msg03651.txt.bz2 List-Id: Hi, The compiler (g++ 3.4.2) gives me an error when i write: B b; vectorelemA(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(*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]' 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=19169