From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CBF6E3858D3C; Tue, 21 Mar 2023 23:31:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBF6E3858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679441491; bh=sU0RZJcrfE4OxDtUoLFhpCprLc6ebgf4A6FUoLSMCkM=; h=From:To:Subject:Date:From; b=VWjr4cLnBM0RNgYBHmxg2t+hu9LjqzIh0MXe0tTdDcmnSaCevY+/CjhZZodGpCUru GlxoTpijr0B23BXT3ih+/HZCi7nUOI72y9EyAhzX3kIOYBwCHF5GQ7NXLHymfg6PSI s3ryykyg3SVoczoef4194p+MOlU/UoZRSVXivAdI= From: "pkasting at google dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109242] New: C++2b std::optional::transform omits required std::remove_cv_t from return optional type Date: Tue, 21 Mar 2023 23:31:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pkasting at google 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D109242 Bug ID: 109242 Summary: C++2b std::optional::transform omits required std::remove_cv_t from return optional type Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: pkasting at google dot com Target Milestone: --- The implementation of C++2b's std::optional::transform() on HEAD omits a ca= ll to std::remove_cv_t when determining the value type of the returned optiona= l. As a result valid code such as the following example is rejected: https://godbolt.org/z/hG5hnz59e #include struct S { int i; }; void foo() { std::optional().transform(&S::i); } Per https://en.cppreference.com/w/cpp/utility/optional/transform, the retur= ned type should always be computed via std::remove_cv_t<> on the invoke_result,= but per https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dblob;f=3Dlibstdc%2B%2B-v3/include/= std/optional;hb=3DHEAD, _Up consistently omits this.=