From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hamza.pair.com (hamza.pair.com [209.68.5.143]) by sourceware.org (Postfix) with ESMTPS id CD81F3858D20 for ; Sat, 28 Jan 2023 11:14:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD81F3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=pfeifer.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=pfeifer.com Received: from hamza.pair.com (localhost [127.0.0.1]) by hamza.pair.com (Postfix) with ESMTP id 81D0833E77 for ; Sat, 28 Jan 2023 06:14:49 -0500 (EST) Received: from naga.localdomain (188-23-1-149.adsl.highway.telekom.at [188.23.1.149]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by hamza.pair.com (Postfix) with ESMTPSA id 1D71733E74 for ; Sat, 28 Jan 2023 06:14:48 -0500 (EST) Date: Sat, 28 Jan 2023 12:14:47 +0100 (CET) From: Gerald Pfeifer To: gcc-patches@gcc.gnu.org Subject: [pushed, C++] wwwdocs: faq: Remove "Copy constructor access check" entry MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Scanned-By: mailmunge 3.10 on 209.68.5.143 Message-Id: <20230128111449.81D0833E77@hamza.pair.com> X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Sometimes less is more (and our FAQ can use some trimming/updating for sure). Pushed. Gerald This entry refers to changes in GCC 3.4 and GCC 4.3 which were released in 2004 and 2008, respectively, and this is hardly a FAQ any more. --- htdocs/bugs/index.html | 50 ------------------------------------------ 1 file changed, 50 deletions(-) diff --git a/htdocs/bugs/index.html b/htdocs/bugs/index.html index aaef8915..96a5d0f0 100644 --- a/htdocs/bugs/index.html +++ b/htdocs/bugs/index.html @@ -605,56 +605,6 @@ a parse error before the character : (the colon before

The simplest way to avoid this is to write std::vector< ::X>, i.e. place a space between the opening angle bracket and the scope operator.

- - -
Copy constructor access check while initializing a -reference.
- -

Consider this code:

- -
-class A 
-{
-public:
-  A();
-
-private:
-  A(const A&);   // private copy ctor
-};
-
-A makeA(void);
-void foo(const A&);
-
-void bar(void)
-{
-  foo(A());       // error, copy ctor is not accessible
-  foo(makeA());   // error, copy ctor is not accessible
-
-  A a1;
-  foo(a1);        // OK, a1 is a lvalue
-}
- -

Starting with GCC 3.4.0, binding an rvalue to a const reference requires -an accessible copy constructor. This might be surprising at first sight, -especially since most popular compilers do not correctly implement this -rule.

- -

The C++ Standard says that a temporary object should be created in -this context and its contents filled with a copy of the object we are -trying to bind to the reference; it also says that the temporary copy -can be elided, but the semantic constraints (eg. accessibility) of the -copy constructor still have to be checked.

- -

For further information, you can consult the following paragraphs of -the C++ standard: [dcl.init.ref] wwwdocs:/5, bullet 2, sub-bullet 1, and -[class.temporary] wwwdocs:/2.

- -

Starting with GCC 4.3.0, GCC no longer gives an error for this -case. This change is based on the -intent -of the C++ language committee. As of 2010-05-28, the final -proposed draft of the C++0x standard permits this code without error.

-

Common problems when upgrading the compiler

-- 2.39.1