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

            Bug ID: 102970
           Summary: stable_sort uninitialized value with -funroll-loops
                    -fno-tree-vectorize
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dan at stahlke dot org
  Target Milestone: ---

Created attachment 51682
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51682&action=edit
demonstration source code

The attached file, compiled with 11.2.0, using the command line in the comment,
causes std::stable_sort to access uninitialized memory.  In fact, it already
goes wrong by the time it passes the inputs to the first comparison operation. 
The problem goes away if the copy constructor of the box struct is defaulted
(see the "#if").

It only happens with "-funroll-loops -fno-tree-vectorize".

Here is a Godbolt: https://godbolt.org/z/6PsdPj6q3

Reply via email to