From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 763933851C0C; Wed, 30 Jun 2021 16:08:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 763933851C0C From: "general at yhf8377 dot me" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/101274] New: std::execution::seq has incorrect behaviour under GCC 11.1.0 Date: Wed, 30 Jun 2021 16:08:04 +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.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: general at yhf8377 dot me 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 attachments.created 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, 30 Jun 2021 16:08:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101274 Bug ID: 101274 Summary: std::execution::seq has incorrect behaviour under GCC 11.1.0 Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: general at yhf8377 dot me Target Milestone: --- Created attachment 51091 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D51091&action=3Dedit Minimal code to reproduce the error We have a unit test that passes when compiled with GCC 10 but fails when compiled with GCC 11. Further digging shows that calling `std::reduce()` wi= th execution policy `std::execution::seq` does not execute the provided functi= on object in sequential order. Attached is the minimal test case that shows the different behaviour under = GCC 10 and GCC 11. Under GCC 10 (10.3.0) the output is: plus_squared_ignore_nan: a =3D nan, b =3D 336.88 plus_squared_ignore_nan: a =3D 113488, b =3D nan plus_squared_ignore_nan: a =3D 113488, b =3D 818.6 plus_squared_ignore_nan: a =3D 783594, b =3D nan plus_squared_ignore_nan: a =3D 783594, b =3D 521.16 plus_squared_ignore_nan: a =3D 1.0552e+06, b =3D 451.78 plus_squared_ignore_nan: a =3D 1.25931e+06, b =3D 601.78 plus_squared_ignore_nan: a =3D 1.62145e+06, b =3D 709.2 plus_squared_ignore_nan: a =3D 2.12441e+06, b =3D 262.55 plus_squared_ignore_nan: a =3D 2.19334e+06, b =3D 659.67 plus_squared_ignore_nan: a =3D 2.62851e+06, b =3D 56.6 plus_squared_ignore_nan: a =3D 2.63171e+06, b =3D 780.31 plus_squared_ignore_nan: a =3D 3.2406e+06, b =3D 398.74 Correct! sum_squared =3D=3D 3399588.6719 Under GCC 11 (11.1.0) the output is: plus_squared_ignore_nan: a =3D 336.88, b =3D nan plus_squared_ignore_nan: a =3D 818.6, b =3D nan plus_squared_ignore_nan: a =3D 336.88, b =3D 818.6 plus_squared_ignore_nan: a =3D nan, b =3D 670443 plus_squared_ignore_nan: a =3D 521.16, b =3D 451.78 plus_squared_ignore_nan: a =3D 601.78, b =3D 709.2 plus_squared_ignore_nan: a =3D 204626, b =3D 503566 plus_squared_ignore_nan: a =3D 4.49494e+11, b =3D 2.53579e+11 plus_squared_ignore_nan: a =3D 262.55, b =3D 659.67 plus_squared_ignore_nan: a =3D 56.6, b =3D 780.31 plus_squared_ignore_nan: a =3D 435427, b =3D 608940 plus_squared_ignore_nan: a =3D 6.43025e+22, b =3D 3.70809e+11 plus_squared_ignore_nan: a =3D 2.01802e+23, b =3D 398.74 gcc_test: src/main.cpp:24: int main(int, char**): Assertion `sum_squared = =3D=3D 3399588.6719' failed. Aborted=