From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 125493858409; Sun, 9 Jul 2023 18:26:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 125493858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688927210; bh=iaqcekeW83iZadXJGiJO4/MwGGvZAX1H0wgbn6J8Jzc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HgVbiD5eV4gwOTOIArMxk2e/93HYGlHtscZBWSlRdw3jjdmB5aLglHInoxgJc+hY7 sF0zxumSKUMR5iEEQKEviSNqoMNJePxvm0+32syAxkfG3lSpnkUmLGZA+H9nNn67RS P0UWVukrHRQfyaJmG3LhtQHg3zHcbzFaK+hsBA4g= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110580] [14 Regression] gcc fails to typecheck nix-2.16.1 source: error: invalid initialization of reference of type Date: Sun, 09 Jul 2023 18:26:49 +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: 14.0 X-Bugzilla-Keywords: needs-bisection, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 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=3D110580 --- Comment #3 from Andrew Pinski --- Reduced all the way: ``` template struct remove_reference { using type =3D __remove_reference(_Tp); }; template using remove_reference_t =3D typename remove_reference<_Tp>::type; template inline constexpr bool is_same_v =3D __is_same(_Tp, _Up); template class s3 { public: template > static constexpr bool __usable_key =3D is_same_v; template void f(_Args __args, int t) { if constexpr (__usable_key<_Args>) { const _Key &__k =3D __args; } } }; struct s0 {}; struct s1 {}; s1 g(); void createMember(int member, s3 &children) { children.f(g(), member); } ``` Or if using the internal type_traits is bad idea here is better testcase: ``` #include using namespace std; template class s3 { public: template > static constexpr bool __usable_key =3D is_same_v; template void f(_Args __args, int t) { if constexpr (__usable_key<_Args>) { const _Key &__k =3D __args; } } }; struct s0 {}; struct s1 {}; s1 g(); void createMember(int member, s3 &children) { children.f(g(), member); } ``` Here is a testcase using static assert rather than if constexpr: ``` #include using namespace std; template class s3 { public: template > static constexpr bool __usable_key =3D is_same_v; template void f(_Args __args, int t) { static_assert(!__usable_key<_Args>); } }; struct s0 {}; struct s1 {}; s1 g(); void createMember(int member, s3 &children) { children.f(g(), member); } ```=