From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6E9EE385C019; Tue, 7 Apr 2020 09:00:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E9EE385C019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586250002; bh=d8YYwhUJ/26Fx2CPoqQ7/pbv7woV4OKCnjNPe7Gz4bw=; h=From:To:Subject:Date:From; b=C/b85/1wT/D+Gy8TZA2ss/Ygd7tzckP7QdX8GtkKKubuXRxYlcntanUHzp89wDcNi OrOXe7qZkc2i2xUhzipQJHPsPNOv11TH6Bw0wnOmVtLFSDbi5CmUEW6OgeXo1HdYB7 n1lLo2+OpUs60uxZJxaM7HMVkOOfXQCWxPleRKbI= From: "pacoarjonilla at yahoo dot es" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94511] New: User-defined type in non-type template parameter yields an incorrect value Date: Tue, 07 Apr 2020 09:00:02 +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: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pacoarjonilla at yahoo dot es 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 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:00:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94511 Bug ID: 94511 Summary: User-defined type in non-type template parameter yields an incorrect value Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pacoarjonilla at yahoo dot es Target Milestone: --- g++ --std=3Dc++2a code.cc && ./a.out The following snippet misbehaves with GCC9 and GCC10 master <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #include #include struct A { std::byte data [6] {static_cast(0x00)}; constexpr A(char ch) { data[ch/8] |=3D static_cast(0x01 << (ch % 8)); } }; template struct B { char ch; }; void print(A a) { for (int i =3D 0; i < 6; i++) std::cout << (unsigned)a.data[i] << ' '; std::cout << std::endl; } using Bn =3D B<{'\n'}>; // XXX Replacing \n by any other character less tha= n 48 corrects the issue XXX using Ba =3D B<{'.'}>; template void foo () { print(T); } int main() { foo<'*'>(); // XXX Replacing the * also corrects the issue XXX print(A{'*'}); } <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Expected output 0 0 0 0 0 4=20 0 0 0 0 0 4=20 Actual output 0 4 0 0 0 0=20 0 0 0 0 0 4=