From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 98C74388206F for ; Fri, 14 Jun 2024 10:26:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 98C74388206F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 98C74388206F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718360781; cv=none; b=dnMfKUDxIgK/98FHLfrMenIGVyH5ziDcLjnFLfPBUNDqxv8li5JBDN4hmTLL3Fzi+qQDDw+1VTUKMf0++ErzTOJYGsjALy6QdZY+VpSoIMnpZE+umpEk9HqcHYriiDpjoAB7/tMufkAylvjyxq7hl2GdaC7BsuW91byReuJV5NA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718360781; c=relaxed/simple; bh=57/d3YOrrWXwCreooU06BrTqtL4PI5C/6Q+3CRed0ak=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=OuEAtpiKxDNAG0iqM/4Z9WQa2rUEdYGZf7cZznKn1SFSGbrw1GJWLeKf5xwt38TcrTaFT3EwkvM5WLNxsOB/CFCbqcacJQY0XrGnBl3mAd1tuBnh3dv1As+EZpqvJwcLhI/+CTqHBUJU5Wn5Kni2IRBeV8HohIdUz6+Mx8O13+I= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718360779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mMfSsnfQ3dpC1V5h6XM66XovYQOpOSuucjTssl4QKZA=; b=g7X6F07S42opwIMGTi1xNCZiYXTqbEqkA2+cPL8yI+jdhONFIrzVYXB4OVwJca9sAJ6N+U z6A7ucpZifLjWH0ywJIUcvi361XgOQwsdem5JP6JSFbPS3PGjCrHUHmN1RZyQVGh1s3Kqu Tslchn2C1neyBk6LpG64maUi2TWNmOE= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-39-kY1iyzgAPSargcOD5oMqvQ-1; Fri, 14 Jun 2024 06:26:16 -0400 X-MC-Unique: kY1iyzgAPSargcOD5oMqvQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D956F19560B1; Fri, 14 Jun 2024 10:26:14 +0000 (UTC) Received: from localhost (unknown [10.39.192.128]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BA9C81955E91; Fri, 14 Jun 2024 10:26:13 +0000 (UTC) Date: Fri, 14 Jun 2024 11:26:12 +0100 From: Jonathan Wakely To: Roger Sayle Cc: gcc-patches@gcc.gnu.org, 'David Malcolm' Subject: Re: [analyzer PATCH] Restore bootstrap with g++ 4.8. Message-ID: References: <026701dab90a$2cae4180$860ac480$@nextmovesoftware.com> MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 14/06/24 10:36 +0100, Jonathan Wakely wrote: >On 07/06/24 19:40 +0100, Roger Sayle wrote: >> >>This patch restores bootstrap when using g++ 4.8 as a host compiler. >>Returning a std::unique_ptr requires a std::move on C++ compilers >>(pre-C++17) that don't guarantee copy elision/return value optimization. > >It doesn't though. The C++17 guaranteed copy elision rules are not >relevant here. This is about lookup for the constructor used in the >return statement, and whether that lookup considers the variable to be >an lvalue or an rvalue. C++11 already says this is valid: > >i#include > >std::unique_ptr f() >{ > std::unique_ptr m; > return m; >} > >See C++11 12.8 [class.copy] p31: > > This elision of copy/move operations, called copy elision, is > permitted in the following circumstances (which may be combined to > eliminate multiple copies): > > - in a return statement in a function with a class return type, when > the expression is the name of a non-volatile automatic object (other > than a function or catch-clause parameter) with the same cv- > unqualified type as the function return type, the copy/move > operation can be omitted by constructing the automatic object > directly into the function’s return value > >and then p32: > > When the criteria for elision of a copy operation are met or would > be met save for the fact that the source object is a function > parameter, and the object to be copied is designated by an lvalue, > overload resolution to select the constructor for the copy is first > performed as if the object were designated by an rvalue. > >The constructor isn't required to be elided in C++11, but the compiler >is required to use a move constructor instead of a copy constructor, >if a move constructor is available. So you don't need to use std::move >on the return value. > >And the code above compiles fine with gcc 4.8.5 on CentOS 7 (and even >with 4.7.1). > >So the std::move calls you've added are redundant, and will cause >-Wredundant-move warnings. > >What's the error you were seeing? I can reproduce it: /home/test/src/gcc/gcc/analyzer/constraint-manager.cc: In member function ‘std::unique_ptr ana::equiv_class::make_dump_widget(const text_art::dump_widget_info&, unsigned int) const’: /home/test/src/gcc/gcc/analyzer/constraint-manager.cc:1179:10: error: cannot bind ‘std::unique_ptr’ lvalue to ‘std::unique_ptr&&’ return ec_widget; ^ Odd ... I'm looking into it ...