From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D34E6385841D; Tue, 28 Feb 2023 15:16:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D34E6385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677597363; bh=iaMgSvvCsK5kijAmIwb3bUeBG2XHu8C6xVthNqAjVhM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=B/cmwYDEZTfbrDbjoXn47yJMuZgRkHIEJqly11FIbSqlmHe4NovhXNj4TsGOruZfk mFonA7jFxq/fQAUpt0Odo+O1v39xXvxBu68ax5+ApFedM1QvA2LAG7xi43/bNrqXqr rcdwK3KhYR8EgPwJx8f+70p85LqGmc5pezePX85Y= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108550] [10/11/12/13 Regression] the type 'const auto' of 'constexpr' variable is not literal Date: Tue, 28 Feb 2023 15:16:02 +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: 11.3.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108550 --- Comment #9 from CVS Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:d918c3a221434521f90cc9b63d5d87f5129e9231 commit r13-6377-gd918c3a221434521f90cc9b63d5d87f5129e9231 Author: Marek Polacek Date: Tue Feb 21 19:13:59 2023 -0500 c++: variable template and targ deduction [PR108550] In this test, we get a bogus error because we failed to deduce the auto= in constexpr auto is_pointer_v =3D is_pointer::value; to bool. Then ensure_literal_type_for_constexpr_object thinks the obje= ct isn't literal and an error is reported. This is another case of the interaction between tf_partial and 'auto', where the auto was not reduced so the deduction failed. In more detail: we have Wrap1() in the code and we need to perform OR -> fn_type_unification. The targ list is incomplete, so we do tsubst_flags_t ecomplain =3D complain | tf_partial | tf_fndecl_ty= pe; fntype =3D tsubst (TREE_TYPE (fn), explicit_targs, ecomplain, NULL_TREE); where TREE_TYPE (fn) is struct integral_constant (void). Then we substitute the return type, which results in tsubsting is_pointer_v. is_pointer_v is a variable template with a placeholder type: template constexpr auto is_pointer_v =3D is_pointer::value; so we find ourselves in lookup_and_finish_template_variable. tf_partia= l is still set, so finish_template_variable -> instantiate_template -> tsubst won't reduce the level of auto. But then we do mark_used which eventua= lly calls do_auto_deduction which clears tf_partial, because we want to rep= lace the auto now. But we hadn't reduced auto's level so this fails. And since we're not in an immediate context, we emit a hard error. I suppose that when we reach lookup_and_finish_template_variable it's probably time to clear tf_partial. (I added an assert and our testsuite doesn't have a test whereby we get to lookup_and_finish_template_variab= le while tf_partial is still active.) PR c++/108550 gcc/cp/ChangeLog: * pt.cc (lookup_and_finish_template_variable): Clear tf_partial. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/var-templ70.C: New test. * g++.dg/cpp1y/var-templ71.C: New test. * g++.dg/cpp1y/var-templ72.C: New test.=