From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A6B323858C20; Fri, 28 Apr 2023 11:50:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A6B323858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682682640; bh=b1wtj6XpEXJO1vYVpO5r2E5EzreoqySr8r6T8KocR2w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=k1T8pdQHLLrLGIvgiey/1LQoSwXZN59/tkuLxmbo0KuDWEkyKfzi5VtK6JAlWIFd4 UeGhWpd7jDtAopc88FbsWVUkfLz2wJyihvcOmpiRZJ7FpeHzs4CkpACRnvjEvrGYQZ pmSUGdKqh8HFNWh/n4NtFZg5diIUdWwaTw3GDTm4= From: "carlosgalvezp at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109663] False positive? Converting from initializer list would use explicit constructor Date: Fri, 28 Apr 2023 11:50:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: carlosgalvezp at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109663 --- Comment #2 from Carlos Galvez --- I could reduce it to a simpler self-contained example: struct Foo; Foo const& foo_maker(); struct Bar { explicit Bar(Foo const&); }; void baz() { Bar const& b{foo_maker()}; } Godbolt: https://godbolt.org/z/1q45Ebexz Here it's clear that we are initializing a reference from a temporary, but since it's a const reference, shouldn't it extend the lifetime of the temporary? Clang does not complain in this case (it does when the reference= is non-const).=