From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0D3D73858039; Wed, 2 Feb 2022 15:13:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D3D73858039 From: "ppalka at gcc dot gnu.org" 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: Wed, 02 Feb 2022 15:13:01 +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: ppalka at gcc dot gnu.org 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: Wed, 02 Feb 2022 15:13:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104255 --- Comment #5 from Patrick Palka --- (In reply to qingzhe huang from comment #4) > (In reply to Patrick Palka from comment #2) >=20 > >=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 sign= ature > > of the function. >=20 > Sorry for my being unable to grasp your meaning before. Now I can see your > point that the "e" of A is from declaration of parameter of function > "g". Now that we agree the value from parameter clause should not be used= in > trailing return type, then it should also not be used in requires clause > etc.=20 > (https://eel.is/c++draft/basic.scope.param#1.3) > But this works: >=20 > template > auto f(int n) requires (n>0); That's because the constraint-expression of a requires clause is an unevalu= ated operand (wg21.link/temp.pre#9.sentence-4). (Though I think this example is strictly speaking ill-formed no diagnostic required because the constraint = can never be satisfied (wg21.link/temp.res.general#6.2).) The check in question is in finish_id_expression_1: /* Also disallow uses of function parameters outside the function body, except inside an unevaluated context (i.e. decltype). */ if (TREE_CODE (decl) =3D=3D PARM_DECL && DECL_CONTEXT (decl) =3D=3D NULL_TREE && !cp_unevaluated_operand) { *error_msg =3D G_("use of parameter outside function body"); return error_mark_node; } >=20 > This is violating our assumption. So, I am not convinced that=20 > (https://eel.is/c++draft/basic.scope.param#note-1) > "A function parameter cannot be used for its value within the > parameter-declaration-clause" is really meaningful. Or I misunderstand it= ??? We should probably relax the above check to permit uses of function paramet= ers with empty types even outside of unevaluated contexts, since we don't really care about the value of an empty type.=