From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17264 invoked by alias); 27 Aug 2005 20:01:43 -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 17253 invoked by uid 22791); 27 Aug 2005 20:01:37 -0000 Received: from front1.tbaytel.net (HELO tbaytel.net) (216.211.26.100) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sat, 27 Aug 2005 20:01:37 +0000 Received: from dummy.name; Sat, 27 Aug 2005 16:01:35 -0400 From: Garrett Kajmowicz Reply-To: gkajmowi@tbaytel.net To: gcc-help@gcc.gnu.org Subject: Problems with temporaries and C++ spec Date: Sat, 27 Aug 2005 20:01:00 -0000 User-Agent: KMail/1.8.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200508271604.35552.gkajmowi@tbaytel.net> X-SW-Source: 2005-08/txt/msg00268.txt.bz2 I'm working on my own C++ library for embedded applications (cxx.uclibc.org) 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 #include class copy_to; class hidden_copying{ public: friend class copy_to; friend class copy_from; private: hidden_copying() : q(0) { } hidden_copying(const hidden_copying &); hidden_copying & operator=(const hidden_copying &); int q; }; 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; }; 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 = r; return retval; } private: int r; }; int main(){ copy_from a(5); copy_to b(a.data()); std::cout << "Value of copy_to: " << b.getval() << std::endl; return 0; } 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 Without breaking valarray spec (in the above case, amounting to making any 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. Thank you for your help. - Garrett