From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C69FA385C019; Tue, 7 Apr 2020 09:51:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C69FA385C019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586253117; bh=eZknn8p0PDt/lIwYAnCopcHAKaCjKcL+0QEWuaGS4AQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ni0OIp4fTHI82HFPqUzkxA9nu+VBMoSLjj0jzsQXbYn4CPItVoi2BH3I1Lef+mYNZ En6w80jiA/g70fPudz+tMGOPYBfIHBLHgQR7NHEo9IkOp9hDv/kWWMBta5VSPJX7At BPkIqWcKo2/jNccw6lmGQv4DJI8yz4IyZlM6zqsE= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94511] User-defined type in non-type template parameter yields an incorrect value Date: Tue, 07 Apr 2020 09:51:57 +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: 10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Apr 2020 09:51:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94511 --- Comment #3 from Jakub Jelinek --- Note, the testcase isn't portable, so either would need to be restricted for ascii compatible execution charsets only, or the check would need to be replaced with i =3D=3D ('*' / 8) ? 1U << ('*' % 8) : 0 (and deal with '*' >=3D 64 where it would be a compile time error). Or use '\x0a' and '\x2a' instead of '\n' and '*'. namespace std { enum class byte : unsigned char {}; constexpr byte operator| (byte __l, byte __r) noexcept { return (byte)(unsigned char)((unsigned)__l | (unsigned)__r); } constexpr byte& operator|=3D (byte& __l, byte __r) noexcept { return __l =3D __l | __r; } } struct A { std::byte data [6] {static_cast (0x00)}; constexpr A (char ch) { data[ch/8] |=3D static_cast(0x01 << (c= h % 8)); } }; template struct B { char ch; }; void check (A a) { for (int i =3D 0; i < 6; i++) if ((unsigned) a.data[i] !=3D (i =3D=3D 5 ? 4 : 0)) __builtin_abort (); } using Bn =3D B<{'\x0a'}>; template void foo () { check (T); } int main () { foo<'\x2a'> (); check (A{'\x2a'}); }=