From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 84BFC3842414; Wed, 9 Dec 2020 15:43:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84BFC3842414 From: "emmanuel.le-trong@cnrs-orleans.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98216] New: [C++20] std::array template parameter error with negative values Date: Wed, 09 Dec 2020 15:43:15 +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: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: emmanuel.le-trong@cnrs-orleans.fr 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: Wed, 09 Dec 2020 15:43:15 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98216 Bug ID: 98216 Summary: [C++20] std::array template parameter error with negative values Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: emmanuel.le-trong@cnrs-orleans.fr Target Milestone: --- Sorry for the bad title, I can't figure out how to summarize this: #include #include using an_array =3D std::array ; constexpr auto add_array (an_array a, an_array const& b) { a[0] +=3D b[0]; return a; } template struct wrapper { static constexpr auto arr =3D A; }; template auto add (wrapper const&, wrapper const&) { return wrapper {}; } constexpr auto ONE =3D an_array {{ 1. }}; constexpr auto MINUS_ONE =3D an_array {{ -1. }};=20 constexpr auto MINUS_TWO =3D an_array {{ -2. }};=20 int main () { auto a =3D wrapper {}; auto b =3D wrapper {}; auto c =3D add (a, b); assert (c.arr =3D=3D MINUS_TWO); // <- should fail assert (c.arr =3D=3D MINUS_ONE); // <- should pass } Compiled with version 11.0.0 20201209, the first assertion passes and the second fails. It should be the opposite. FWIW, if you replace double by float, it works as intended.=