From patchwork Sat Jan 28 11:14:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerald Pfeifer X-Patchwork-Id: 49846 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1294007wrn; Sat, 28 Jan 2023 03:15:24 -0800 (PST) X-Google-Smtp-Source: AK7set/jsHlz1txIC08lZU1iw4XbDbY/uxJmynzCXvjEi7zyWn3L/52ctgACOLI5uq/28cd+7Hvp X-Received: by 2002:a17:906:af74:b0:87b:dac0:b23b with SMTP id os20-20020a170906af7400b0087bdac0b23bmr5161173ejb.55.1674904523999; Sat, 28 Jan 2023 03:15:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674904523; cv=none; d=google.com; s=arc-20160816; b=nd1PcpRKH2TybcoAv3Z12h2/vvalMwD9XSfJN//Lagw2SKTy1zEPaoxrIAwXBEOXR8 toiJPganAw2a9tN9ROBxcE7e8ZV3iBaj63GXATD8eH47df/JGqYwUnqI/8nHSv9eIurQ T4UcmMSbxU7aR9ORYVxsnGbORu/89o6OdIICtzBFmswMNyMKp1/36vA6NuCS5U4KbbQt RKSqyMzg1l/aYSOqERK0dqFYyYSfkN8nxhvIpKlz/9RoLsE6MGK7Vg+RuQEQzLp+8wOe Wpl8nboNxAt6/EKJEYn0FwsCNUOwqU2Hm+DYbiQqwUCpyujjc12zl5mHTqXavJOqyFoZ icLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:mime-version:subject :to:from:date:dmarc-filter:delivered-to; bh=4iHiGrzmh1DzW/p3Rw5LjSoSWUnxdcz4DapCkQqS9OE=; b=Rmz2+YKnlId9NWKt+OQVsfdiRe+lg78YtgMUjwB/m5AC+frgvEC7g3n05bhigHnYN1 wDzRV5zhjLYH/vt6Y4B1FMpBVd4mKeLZf/Ckusc6t+c8+eXiw4csUmJKIi51QbDUwH0N 7sj0QCQTnfxk9qw7GdO/UyxVWIMaBQEWXGp4px9WeyCDKkGZyOdC0ZSYkUJwwxdRu2ki 8nNTjYD896tqPyDkXbYpVXMueUaTaMaTOF+TEhPLCeIGSBSc88z69MM/GhTYtJTm1xD/ OihwY74Ym+3usbKwKa8ou/cI4u1hLG/424qYybeN0oQq9EEyKaJI20T2tL5da+Z/1tOe Uk6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f17-20020a170906739100b007c0a81df4b6si8768035ejl.707.2023.01.28.03.15.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Jan 2023 03:15:23 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 076FC3858417 for ; Sat, 28 Jan 2023 11:15:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756264686142305511?= X-GMAIL-MSGID: =?utf-8?q?1756264686142305511?= 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