public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "general at yhf8377 dot me" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-101274-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101274

            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=51091&action=edit
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()` with
execution policy `std::execution::seq` does not execute the provided function
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 = nan, b = 336.88
plus_squared_ignore_nan: a = 113488, b = nan
plus_squared_ignore_nan: a = 113488, b = 818.6
plus_squared_ignore_nan: a = 783594, b = nan
plus_squared_ignore_nan: a = 783594, b = 521.16
plus_squared_ignore_nan: a = 1.0552e+06, b = 451.78
plus_squared_ignore_nan: a = 1.25931e+06, b = 601.78
plus_squared_ignore_nan: a = 1.62145e+06, b = 709.2
plus_squared_ignore_nan: a = 2.12441e+06, b = 262.55
plus_squared_ignore_nan: a = 2.19334e+06, b = 659.67
plus_squared_ignore_nan: a = 2.62851e+06, b = 56.6
plus_squared_ignore_nan: a = 2.63171e+06, b = 780.31
plus_squared_ignore_nan: a = 3.2406e+06, b = 398.74

Correct! sum_squared == 3399588.6719

Under GCC 11 (11.1.0) the output is:

plus_squared_ignore_nan: a = 336.88, b = nan
plus_squared_ignore_nan: a = 818.6, b = nan
plus_squared_ignore_nan: a = 336.88, b = 818.6
plus_squared_ignore_nan: a = nan, b = 670443
plus_squared_ignore_nan: a = 521.16, b = 451.78
plus_squared_ignore_nan: a = 601.78, b = 709.2
plus_squared_ignore_nan: a = 204626, b = 503566
plus_squared_ignore_nan: a = 4.49494e+11, b = 2.53579e+11
plus_squared_ignore_nan: a = 262.55, b = 659.67
plus_squared_ignore_nan: a = 56.6, b = 780.31
plus_squared_ignore_nan: a = 435427, b = 608940
plus_squared_ignore_nan: a = 6.43025e+22, b = 3.70809e+11
plus_squared_ignore_nan: a = 2.01802e+23, b = 398.74
gcc_test: src/main.cpp:24: int main(int, char**): Assertion `sum_squared ==
3399588.6719' failed.
Aborted

             reply	other threads:[~2021-06-30 16:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-30 16:08 general at yhf8377 dot me [this message]
2021-06-30 16:09 ` [Bug c++/101274] " general at yhf8377 dot me
2021-07-01  7:17 ` [Bug libstdc++/101274] [11/12 Regression] " rguenth at gcc dot gnu.org
2021-07-01  7:56 ` marxin at gcc dot gnu.org
2021-07-01 18:54 ` rodgertq at gcc dot gnu.org
2021-07-02  1:03 ` rodgertq at gcc dot gnu.org
2021-07-02 12:00 ` general at yhf8377 dot me
2021-07-02 16:47 ` rodgertq at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-101274-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).