From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 519583858C54; Sun, 28 Jan 2024 21:51:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 519583858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706478685; bh=KGKQm+2FmZ/IQrB8p4DVo19pi9UuRTOLmlPwmk2MnjY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Jmlv0mUokYRpd/1hcB4FMzO9CK5PwcD/CZn2g9tsmscqFeIQxBqkPYeopuy9N/bzo SjaYtKx28OuYSNrOk9gDyQhSEoZNHurc/6yEG+Z7jO2nCEWXGUYa03hZTF11Ghi41I 7Ai3ifXVNr63hM7rBCNl6jZi6bNRf7X3ILRXWMTs= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113638] [13/14 Regression] Array bounds of variable templates are not correctly deduced from initializers since GCC13 inside a decltype/sizeof Date: Sun, 28 Jan 2024 21:51:24 +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: 13.2.1 X-Bugzilla-Keywords: needs-bisection, wrong-code 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: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed cf_reconfirmed_on bug_status 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=3D113638 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2024-01-28 Status|UNCONFIRMED |NEW --- Comment #2 from Andrew Pinski --- Confirmed. Simplified testcase: ``` template constexpr int my_array[]{Is...}; constexpr auto t1 =3D my_array<2>; static_assert(sizeof(my_array<1>) =3D=3D sizeof(int) * 1); ``` If we change the t1 variable definition to use `my_array<1>` instead of `my_array<2>`, then the sizeof works. It seems like we are not fully instantiating the template variable when used inside a decltype/sizeof to figure out the array bounds. An obvious workaround is to do: ``` template constexpr int my_array[sizeof...(Is)]{Is...}; ```=