From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7A411385829A; Mon, 8 Jan 2024 14:50:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A411385829A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704725436; bh=uQLA/+MMt5Mf4rrtRGhTeH18wjP6ELz5L2Vd12bp5Uo=; h=From:To:Subject:Date:From; b=Sbk5lQ7ycU6Yd3UnEajlUH5i2W6R1jRYpXkYsVPHBrFbhUc3qIEjgmOlwWKRNHAef h4cGMxbcbfP+uMaeqSnY4/NyeWAgg+JMcM40JiPAZkVWCiOQZT7JVZYXIyBhalN5az 2cUhwYMXAUTOabOM9/sJ4rK81jt4o3lG+sb+Ysh4= From: "janschultke at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113274] New: Memoization in template parameters is overly aggressive; false memoization for const pointers Date: Mon, 08 Jan 2024 14:50:35 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: janschultke at googlemail 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: 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=3D113274 Bug ID: 113274 Summary: Memoization in template parameters is overly aggressive; false memoization for const pointers Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: janschultke at googlemail dot com Target Milestone: --- ## Minimal Reproducible Example (https://godbolt.org/z/Y7Kr9o546) template struct A { static constexpr bool value =3D false; }; template requires __is_same(decltype(p), int*) struct A

{ static constexpr bool value =3D false; }; int x =3D 0; //static_assert( A<&x>::value ); static_assert( A(&x)>::value =3D=3D false ); ## Explanation Uncommenting the first static_assert causes compilation failure of the seco= nd static_assert. This should definitely not happen, as the following instantiations should be distinct: - A<(int*) &x> - A<(const int*) &x> GCC aggressively memoizes the first instantiation in A<&x>, which results in the subsequent A<(const int*)&x>::value being identical, even though it sho= uld not be.=