From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2F2A93858421; Sun, 10 Sep 2023 08:18:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F2A93858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694333914; bh=RLO1s9LBjp47zZ/cJsoG1fSzYeXGAzVRBYtU/AXe7tI=; h=From:To:Subject:Date:From; b=SyiasEKc4QgPg5Jum7sUyN7jbfmrBGx8fNd86U0l4rgCyq4GO8NfS6Yta0ZleDrI/ oNapzmfOHcleewwP7rPpW7ZtA+LCrmUJTtnMIi4mVBFqqyOceXYVcpKrgt2gBy994k SY4l0xSzlSF590HK8gAR0ZwvqLujSw56RaP/vciQ= From: "de34 at live dot cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/111358] New: libstdc++'s optional::and_then and optional::transform are not ADL-proof Date: Sun, 10 Sep 2023 08:18:32 +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: 14.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: de34 at live dot cn 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 keywords 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=3D111358 Bug ID: 111358 Summary: libstdc++'s optional::and_then and optional::transform are not ADL-proof Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: de34 at live dot cn Target Milestone: --- The following program is incorrectly rejected when using libstdc++ (https://godbolt.org/z/eavTYjEdx): ``` #include namespace fvs { struct Foo {}; void operator*(std::optional) =3D delete; } int main() { std::optional{}.and_then( [](auto&&){ return std::optional{}; }); std::optional{}.transform( [](auto&&){ return 0; }); } ``` The reason of compilation error is that libstdc++ uses **this in and_then a= nd transform functions, which triggers ADL and finds unwanted operator*(). These monadic operations are currently specified in [optional.monadic] with value(), so they should be ADL-proof.=