From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6FE703836C43; Thu, 10 Dec 2020 17:16:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FE703836C43 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98216] [C++20] std::array template parameter error with negative values Date: Thu, 10 Dec 2020 17:16:28 +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: 11.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: redi 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: Thu, 10 Dec 2020 17:16:28 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98216 --- Comment #3 from Jonathan Wakely --- Reduced: struct an_array { constexpr bool operator=3D=3D(const an_array& a) const { return d =3D=3D = a.d; } double d; }; constexpr auto add_array (an_array a, an_array b) { a.d +=3D b.d; return a; } template struct wrapper { static constexpr auto arr =3D A; }; 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 () { #ifndef FIX auto a =3D wrapper {}; __builtin_printf("%f\n", a.arr.d); #endif auto c =3D wrapper {}; __builtin_printf("%f\n", c.arr.d); if (c.arr !=3D MINUS_ONE) __builtin_abort(); } Prints: -2.000000 -2.000000 Aborted (core dumped) If you define FIX (i.e. don't instantiate wrapper first) it work= s: -1.000000=