From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23346 invoked by alias); 28 Aug 2005 04:45:13 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 23306 invoked by uid 22791); 28 Aug 2005 04:45:06 -0000 Received: from zproxy.gmail.com (HELO zproxy.gmail.com) (64.233.162.197) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sun, 28 Aug 2005 04:45:06 +0000 Received: by zproxy.gmail.com with SMTP id n1so485319nzf for ; Sat, 27 Aug 2005 21:45:01 -0700 (PDT) Received: by 10.36.33.9 with SMTP id g9mr521656nzg; Sat, 27 Aug 2005 21:45:01 -0700 (PDT) Received: by 10.37.22.44 with HTTP; Sat, 27 Aug 2005 21:45:01 -0700 (PDT) Message-ID: <2e393d08050827214525510965@mail.gmail.com> Date: Sun, 28 Aug 2005 04:45:00 -0000 From: corey taylor To: gkajmowi@tbaytel.net Subject: Re: Problems with temporaries and C++ spec Cc: gcc-help@gcc.gnu.org In-Reply-To: <200508271604.35552.gkajmowi@tbaytel.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <200508271604.35552.gkajmowi@tbaytel.net> X-SW-Source: 2005-08/txt/msg00271.txt.bz2 Why are you using a private copy constructor there in the first place? corey On 8/27/05, Garrett Kajmowicz wrote: > I'm working on my own C++ library for embedded applications (cxx.uclibc.o= rg) > and while implementing valarray I came across a problem with private copy > contructors. The following code works in GCC 3.3.5, but not in GCC 3.4.2 >=20 > #include >=20 > class copy_to; >=20 > class hidden_copying{ > public: > friend class copy_to; > friend class copy_from; >=20 > private: > hidden_copying() : q(0) { } > hidden_copying(const hidden_copying &); > hidden_copying & operator=3D(const hidden_copying &); > int q; > }; >=20 > class copy_to{ > public: > friend class copy_from; > copy_to() : p (0) { } > copy_to(const hidden_copying & h) : p(h.q) { } > int getval() const{ > return p; > } > private: > int p; > }; >=20 > class copy_from{ > public: > friend class hidden_copying; > copy_from() : r(0) { } > copy_from(const int i) : r(i) { } > copy_from(const copy_from & f) : r(f.r) { } > hidden_copying data() const{ > hidden_copying retval; > retval.q =3D r; > return retval; > } >=20 > private: > int r; > }; >=20 >=20 > int main(){ > copy_from a(5); > copy_to b(a.data()); > std::cout << "Value of copy_to: " << b.getval() << std::endl; > return 0; > } >=20 > With gcc 3.4.2 I receive the following error message: > ../temporarytest.cpp: In function `int main()': > ../temporarytest.cpp:12: error: `hidden_copying::hidden_copying(const > hidden_copying&)' is private > ../temporarytest.cpp:48: error: within this context >=20 > Without breaking valarray spec (in the above case, amounting to making an= y of > the copy constructors of hidden_copying public), how can I get the above = code > work work properly. If There is no way, than please explain how to > reconsile behaviors with spec definition of std::slice_array. >=20 > Thank you for your help. >=20 > - Garrett >