public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rjimenez at ujaen dot es" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/19170] New: Compilation error at a vector definition
Date: Mon, 27 Dec 2004 19:43:00 -0000	[thread overview]
Message-ID: <20041227194302.19170.rjimenez@ujaen.es> (raw)

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


             reply	other threads:[~2004-12-27 19:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-27 19:43 rjimenez at ujaen dot es [this message]
2004-12-27 19:46 ` [Bug c++/19170] " pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041227194302.19170.rjimenez@ujaen.es \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).