From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 731AB3858D38; Sat, 6 Apr 2024 02:37:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 731AB3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712371049; bh=8AHhMXVxUVP+HLRG+ILkeTUEWjTBDcAfQivOyFZV/QM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=puQT8ftZ8yDQJ7ghvro1fBQBbX+eQa2QO4pPjsiDyzZgUR3I/L+gt1CBlPl1dagHn QpOYxQXFoM1ovziu00sLBRzdKmuiQS3AEborhwnUBFdGT4gt+JSYT6oizipydmaDH2 F3MOeww9ly+klURebGvM+F5cqXZujOsxQabSExAg= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/91798] Compiler rejects code due to template specialization of auto parameter value. Date: Sat, 06 Apr 2024 02:37:27 +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: 8.1.0 X-Bugzilla-Keywords: 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: --- 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=3D91798 --- Comment #4 from Andrew Pinski --- Actually maybe GCC is correct here. Remove the variadic template: ``` //Get type parameter at given index. template struct param { static_assert(i > 0, "Index into parameter pack cannot be negative!"); using type =3D typename param::type; }; template<> struct param<0> { using type =3D int; }; int main() { typename param<0u>::type x =3D 'a'; static_cast(x); } ``` Every compiler (EDG, GCC, clang and MSVC) I tried rejects this. Note the original code, EDG rejects it for the same reason as GCC. The reason why is 0 is different 0u as they have different types as they sh= ould not match. Though I think there is a defect report in that area ...=