public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/102970] [11/12 Regression] stable_sort uninitialized value with -funroll-loops -fno-tree-vectorize
Date: Wed, 27 Oct 2021 20:49:14 +0000	[thread overview]
Message-ID: <bug-102970-4-0CpQAslkVO@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102970-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-10-27
     Ever confirmed|0                           |1
             Target|x86_64-linux-gnu            |x86_64-linux-gnu,
                   |                            |aarch64-linux-gnu
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is a self contained example which aborts if it is wrong.
#include <vector>
#include <algorithm>
#include <cassert>

struct box {
   box(int xmin, int xmax, int ymin, int ymax) noexcept
      : m_xmin(xmin),
        m_xmax(xmax),
        m_ymin(ymin),
        m_ymax(ymax) {
   }

   box(box const & o) noexcept
      : m_xmin(o.m_xmin),
        m_xmax(o.m_xmax),
        m_ymin(o.m_ymin),
        m_ymax(o.m_ymax) { }

   int m_xmin;
   int m_xmax;
   int m_ymin;
   int m_ymax;
};


int main() {
    std::vector<box> vRects{ // requires 18 elements
        { 900, 11, 22, 33 },
        { 901, 11, 22, 33 },
        { 902, 11, 22, 33 },
        { 903, 11, 22, 33 },
        { 704, 11, 22, 33 },
        { 705, 11, 22, 33 },
        { 706, 11, 22, 33 },
        { 707, 11, 22, 33 },
        { 808, 11, 22, 33 },
        { 809, 11, 22, 33 },
        { 810, 11, 22, 33 },
        { 811, 11, 22, 33 },
        { 812, 11, 22, 33 },
        { 813, 11, 22, 33 },
        { 814, 11, 22, 33 },
        { 815, 11, 22, 33 },
        { 816, 11, 22, 33 },
        { 817, 11, 22, 33 },
        { 818, 11, 22, 33 },
    };

    std::stable_sort(vRects.begin(), vRects.end(), [](auto const &r1, auto
const &r2) -> bool {
        if (r2.m_xmax==0||r2.m_ymin==0||r2.m_ymax==0){__builtin_abort();}
        return r1.m_xmin < r2.m_xmin;
    });
  return 0;
}

------- CUT -----
-O2 -funroll-loops -fno-tree-vectorize
Is enough (note the -fno-tree-vectorize is needed for the trunk as it is
enabled now at -O2).

Also this happens on aarch64-linux-gnu too.

Confirmed.

  parent reply	other threads:[~2021-10-27 20:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27 19:07 [Bug c++/102970] New: " dan at stahlke dot org
2021-10-27 20:40 ` [Bug middle-end/102970] [11/12 Regression] " pinskia at gcc dot gnu.org
2021-10-27 20:49 ` pinskia at gcc dot gnu.org [this message]
2021-10-27 20:57 ` pinskia at gcc dot gnu.org
2021-11-01 10:04 ` [Bug middle-end/102970] [11/12 Regression] stable_sort uninitialized value with -funroll-loops -fno-tree-vectorize since r11-2963-gd6a05b494b4b714e marxin at gcc dot gnu.org
2021-11-02  7:13 ` rguenth at gcc dot gnu.org
2021-11-03 11:11 ` rguenth at gcc dot gnu.org
2021-11-03 14:00 ` cvs-commit at gcc dot gnu.org
2021-11-03 14:05 ` [Bug middle-end/102970] [11 " rguenth at gcc dot gnu.org
2021-11-22  8:00 ` cvs-commit at gcc dot gnu.org
2021-11-22  8:01 ` rguenth 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-102970-4-0CpQAslkVO@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).