From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 94AD83858418; Fri, 28 Jan 2022 18:48:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94AD83858418 From: "nickhuang99 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104255] parsing function signature fails when it uses a function parameter outside of an unevaluated context Date: Fri, 28 Jan 2022 18:48:53 +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: 12.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: nickhuang99 at hotmail 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2022 18:48:53 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104255 --- Comment #3 from qingzhe huang --- (In reply to Patrick Palka from comment #2) > The error message is obscure, but it seems what GCC has issue with here is > the use of the function parameter seq2 in the trailing return type occurr= ing > outside of an unevaluated context. >=20 The error messages are issued in a cascading fashion, the "outside function parameter" is issued much later which maybe far-fetched from core one, in my guess. > I'm not totally sure if the testcase is valid > (https://eel.is/c++draft/basic.scope.param#note-1 might suggest it's not?= ), > but one workaround is to replace the use of seq2 in the trailing return t= ype > with decltype(seq2){} (which works because index_sequence is an empty typ= e). This is about "parameter-declaration-clause" which is not our case, because "f(e)" is not function declaration part, instead an invoking of function of which "e" is not "declaration" at all, but an argument of function. > Here's a minimal testcase demonstrating the issue >=20 > struct empty { }; > constexpr int f(empty) { return 0; } > template struct A { }; > auto g(empty e) -> A; Again, GCC is only one rejecting this code (https://www.godbolt.org/z/1bvMavKKd) which makes me suspect that GCC may n= ot be correct. > which is rejected with >=20 > error: use of parameter outside function body before =E2=80=98)=E2=80= =99 token >=20 > due to 'e' being used outside of an unevaluated context within the signat= ure > of the function. BTW, this has nothing to do with c++20(no -std=3Dc++20 is needed) which eliminates potential issues of many c++20 new features. Thank you for your simplified case which is a much clearer one to demonstrate the core issue.=