From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A91BE3858D3C; Sun, 27 Nov 2022 19:47:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A91BE3858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669578466; bh=99ykva2w5O9nGFXJ6xms6zdbsxrNGVeO4/duE6raYvs=; h=From:To:Subject:Date:From; b=nbDGBWE+r6ZDAefjmLRisNwn4phHnvF8wnZViIalZ1cKju6rKALGXO9U+Jozs6mdh 7n3Bcic7pUOGTac4wadiVQTQM3ePxRALekiGYdPgrJdjkjf0hdNYxDfLlTkbnTAjtg Y2QshZFd2Sus68qc7BPoAXqXl98Vja0Ozf61AUvE= From: "gcc at nospam dot scs.stanford.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107889] New: Incorrect parsing of qualified friend function returning decltype(auto) Date: Sun, 27 Nov 2022 19:47:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc at nospam dot scs.stanford.edu 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=3D107889 Bug ID: 107889 Summary: Incorrect parsing of qualified friend function returning decltype(auto) Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc at nospam dot scs.stanford.edu Target Milestone: --- G++ 12.2.0 rejects a valid friend declaration for a fully-qualified function returning `decltype(auto)`. To reproduce the problem, you can try to compi= le the following code with `g++ -std=3Dc++20 -c bug.cc`: decltype(auto) f() { } struct S { friend decltype(auto) ::f(); }; This results in the following error: $ c++ -std=3Dc++20 -c bug.cc bug.cc:7:27: error: 'decltype(auto)' is not a class type 7 | friend decltype(auto) ::f(); | ^ bug.cc:7:27: error: 'decltype(auto)' is not a class type bug.cc:7:27: error: 'decltype(auto)' is not a class type bug.cc:7:29: error: 'decltype(auto)' is not a class type 7 | friend decltype(auto) ::f(); | ^ bug.cc:7:10: error: ISO C++ forbids declaration of 'f' with no type [-fpermissive] 7 | friend decltype(auto) ::f(); | ^~~~~~~~~~~~~~ bug.cc:7:29: error: invalid use of 'decltype(auto)' 7 | friend decltype(auto) ::f(); A similar problem was reported in bug #59766 for friend functions returning auto. It seems to have been mostly fixed, but the combination of decltype(auto) and the function name being qualified (::f) is still a probl= em.=