public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100367] New: g++ internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators
@ 2021-05-01  2:51 gccbugzilla at thepirate42 dot org
  2021-05-03 14:30 ` [Bug c++/100367] [11/12 Regression] Internal " ppalka at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gccbugzilla at thepirate42 dot org @ 2021-05-01  2:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100367
           Summary: g++ internal compiler error when
                    std::lexicographical_compare_three_way third and
                    fourth argument are reverse iterators
           Product: gcc
           Version: 11.1.0
               URL: https://godbolt.org/z/jxbaea4fY
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gccbugzilla at thepirate42 dot org
  Target Milestone: ---

When I try to compile this code


#include <vector>
#include <algorithm>

int main(){
  std::vector<int> a(2,1);
  std::vector<int> b(2,1);
 
std::lexicographical_compare_three_way(a.begin(),a.end(),b.rbegin(),b.rend());
  return 0;
}


with this command line


g++ -v -Wall -Wextra -std=c++20 test2.cpp


I get this output:


Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/program\
files/mingw-w64/winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/11.1.0/lto-wrapper.exe
OFFLOAD_TARGET_NAMES=nvptx-none
Target: x86_64-w64-mingw32
Configured with: ../configure
--prefix=/R/winlibs64_stage/inst_gcc-11.1.0/share/gcc
--build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32
--enable-offload-targets=nvptx-none --with-pkgversion='MinGW-W64
x86_64-posix-seh, built by Brecht Sanders' --with-tune=generic
--enable-checking=release --enable-threads=posix --disable-sjlj-exceptions
--disable-libunwind-exceptions --disable-serial-configure --disable-bootstrap
--enable-host-shared --enable-plugin --disable-default-ssp --disable-rpath
--enable-libstdcxx-pch --enable-libstdcxx-time=yes --disable-libstdcxx-debug
--disable-version-specific-runtime-libs --with-stabs --disable-symvers
--enable-languages=c,c++,fortran,lto,objc,obj-c++ --disable-gold --disable-nls
--disable-stage1-checking --disable-win32-registry --disable-multilib
--enable-ld --enable-libquadmath --enable-libada --enable-libssp
--enable-libstdcxx --enable-lto --enable-fully-dynamic-string --enable-libgomp
--enable-graphite --enable-mingw-wildcard
--with-mpc=/d/Prog/winlibs64_stage/custombuilt
--with-mpfr=/d/Prog/winlibs64_stage/custombuilt
--with-gmp=/d/Prog/winlibs64_stage/custombuilt
--with-isl=/d/Prog/winlibs64_stage/custombuilt --enable-install-libiberty
--enable-__cxa_atexit --without-included-gettext --with-diagnostics-color=auto
--enable-clocale=generic --with-libiconv --with-system-zlib
--with-build-sysroot=/R/winlibs64_stage/gcc-11.1.0/build_mingw/mingw-w64
CFLAGS=-I/d/Prog/winlibs64_stage/custombuilt/include/libdl-win32
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) 
COLLECT_GCC_OPTIONS='-v' '-Wall' '-Wextra' '-std=c++20' '-shared-libgcc'
'-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 c:/program
files/mingw-w64/winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/11.1.0/cc1plus.exe
-quiet -v -iprefix c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/
-D_REENTRANT test2.cpp -quiet -dumpdir a- -dumpbase test2.cpp -dumpbase-ext
.cpp -mtune=generic -march=x86-64 -Wall -Wextra -std=c++20 -version -o
C:\Users\piez\AppData\Local\Temp\ccUgxbmg.s
GNU C++20 (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) version 11.1.0
(x86_64-w64-mingw32)
        compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.1, isl version isl-0.23-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "c:/program
files/mingw-w64/winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../include/c++/11.1.0"
ignoring duplicate directory "c:/program
files/mingw-w64/winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../include/c++/11.1.0/x86_64-w64-mingw32"
ignoring duplicate directory "c:/program
files/mingw-w64/winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../include/c++/11.1.0/backward"
ignoring duplicate directory "c:/program
files/mingw-w64/winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.1.0/include"
ignoring nonexistent directory
"R:/winlibs64_stage/inst_gcc-11.1.0/share/gcc/include"
ignoring nonexistent directory
"/R/winlibs64_stage/inst_gcc-11.1.0/share/gcc/include"
ignoring duplicate directory "c:/program
files/mingw-w64/winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.1.0/include-fixed"
ignoring duplicate directory "c:/program
files/mingw-w64/winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../include/c++/11.1.0
 c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../include/c++/11.1.0/x86_64-w64-mingw32
 c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../include/c++/11.1.0/backward
 c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/include
 c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../include
 c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/include-fixed
 c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/include
End of search list.
GNU C++20 (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) version 11.1.0
(x86_64-w64-mingw32)
        compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.1, isl version isl-0.23-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 676ba7a6777cf82fe28eea2a3673909c
In file included from c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\include\c++\11.1.0\vector:60,
                 from test2.cpp:1:
c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\include\c++\11.1.0\bits\stl_algobase.h:
In instantiation of 'constexpr decltype (__comp((* __first1), (* __first2)))
std::lexicographical_compare_three_way(_InputIter1, _InputIter1, _InputIter2,
_InputIter2, _Comp) [with _InputIter1 = __gnu_cxx::__normal_iterator<int*,
std::vector<int> >; _InputIter2 =
std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >;
_Comp = std::compare_three_way; decltype (__comp((* __first1), (* __first2))) =
std::strong_ordering]':
c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\include\c++\11.1.0\bits\stl_algobase.h:1872:35:
  required from 'constexpr auto
std::lexicographical_compare_three_way(_InputIter1, _InputIter1, _InputIter2,
_InputIter2) [with _InputIter1 = __gnu_cxx::__normal_iterator<int*,
std::vector<int> >; _InputIter2 =
std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >]'
test2.cpp:7:41:   required from here
c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\include\c++\11.1.0\bits\stl_algobase.h:1861:24:
  in 'constexpr' expansion of
'std::operator==<__gnu_cxx::__normal_iterator<int*, std::vector<int> >,
__gnu_cxx::__normal_iterator<int*, std::vector<int> > >(((const
std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> >
>&)(& __first2)), ((const
std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> >
>&)(& __last2)))'
c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\include\c++\11.1.0\bits\stl_iterator.h:494:22:
  in 'constexpr' expansion of '(&
__x)->std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int>
> >::base()'
c:\program
files\mingw-w64\winlibs-x86_64-posix-seh-gcc-11.1.0-mingw-w64-8.0.0-r1\mingw64\include\c++\11.1.0\bits\stl_algobase.h:1861:36:
internal compiler error: in cxx_eval_indirect_ref, at cp/constexpr.c:4976
 1861 |       return (__first2 == __last2) <=> true; // See PR 94006
      |              ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.


I get this error only when the third and fourth arguments of
std::lexicographical_compare_three_way are reverse iterators. If I use reverse
iterators in the first and second argument, but not in the third and the
fourth, g++ doesn't complain.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100367] [11/12 Regression] Internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators
  2021-05-01  2:51 [Bug c++/100367] New: g++ internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators gccbugzilla at thepirate42 dot org
@ 2021-05-03 14:30 ` ppalka at gcc dot gnu.org
  2021-05-18 16:21 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-05-03 14:30 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Internal compiler error     |[11/12 Regression] Internal
                   |when                        |compiler error when
                   |std::lexicographical_compar |std::lexicographical_compar
                   |e_three_way third and       |e_three_way third and
                   |fourth argument are reverse |fourth argument are reverse
                   |iterators                   |iterators
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.2
          Component|libstdc++                   |c++
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-05-03

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Seems to be a frontend issue, started with r11-5866.  Reduced:

#include <compare>

struct iter {
  bool current;
  iter(iter &);
};

constexpr bool operator==(const iter &, const iter &__y) {
  return __y.current;
}

void lexicographical_compare_three_way(iter a) {
  (a == a) <=> true;
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100367] [11/12 Regression] Internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators
  2021-05-01  2:51 [Bug c++/100367] New: g++ internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators gccbugzilla at thepirate42 dot org
  2021-05-03 14:30 ` [Bug c++/100367] [11/12 Regression] Internal " ppalka at gcc dot gnu.org
@ 2021-05-18 16:21 ` jason at gcc dot gnu.org
  2021-05-19 20:17 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2021-05-18 16:21 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100367] [11/12 Regression] Internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators
  2021-05-01  2:51 [Bug c++/100367] New: g++ internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators gccbugzilla at thepirate42 dot org
  2021-05-03 14:30 ` [Bug c++/100367] [11/12 Regression] Internal " ppalka at gcc dot gnu.org
  2021-05-18 16:21 ` jason at gcc dot gnu.org
@ 2021-05-19 20:17 ` cvs-commit at gcc dot gnu.org
  2021-05-19 20:17 ` cvs-commit at gcc dot gnu.org
  2021-05-19 20:18 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-19 20:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:cd67343703ef4fa61de837f4690eba70d2760825

commit r12-928-gcd67343703ef4fa61de837f4690eba70d2760825
Author: Jason Merrill <jason@redhat.com>
Date:   Tue May 18 12:29:33 2021 -0400

    c++: ICE with <=> fallback [PR100367]

    Here, when genericizing lexicographical_compare_three_way, we haven't yet
    walked the operands, so (a == a) still sees ADDR_EXPR <a>, but this is
after
    we've changed the type of a to REFERENCE_TYPE.  When we try to fold (a ==
a)
    by constexpr evaluation, the constexpr code doesn't understand trying to
    take the address of a reference, and we end up crashing.

    Fixed by avoiding constexpr evaluation in genericize_spaceship, by using
    fold_build2 instead of build_new_op on scalar operands.  Class operands
    should have been expanded during parsing.

            PR c++/100367
            PR c++/96299

    gcc/cp/ChangeLog:

            * method.c (genericize_spaceship): Use fold_build2 for scalar
            operands.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/spaceship-fallback1.C: New test.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100367] [11/12 Regression] Internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators
  2021-05-01  2:51 [Bug c++/100367] New: g++ internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators gccbugzilla at thepirate42 dot org
                   ` (2 preceding siblings ...)
  2021-05-19 20:17 ` cvs-commit at gcc dot gnu.org
@ 2021-05-19 20:17 ` cvs-commit at gcc dot gnu.org
  2021-05-19 20:18 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-19 20:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:3bdd3e45955ef94a1f2db51a2af1ded54d41f670

commit r11-8437-g3bdd3e45955ef94a1f2db51a2af1ded54d41f670
Author: Jason Merrill <jason@redhat.com>
Date:   Tue May 18 12:29:33 2021 -0400

    c++: ICE with <=> fallback [PR100367]

    Here, when genericizing lexicographical_compare_three_way, we haven't yet
    walked the operands, so (a == a) still sees ADDR_EXPR <a>, but this is
after
    we've changed the type of a to REFERENCE_TYPE.  When we try to fold (a ==
a)
    by constexpr evaluation, the constexpr code doesn't understand trying to
    take the address of a reference, and we end up crashing.

    Fixed by avoiding constexpr evaluation in genericize_spaceship, by using
    fold_build2 instead of build_new_op on scalar operands.  Class operands
    should have been expanded during parsing.

            PR c++/100367
            PR c++/96299

    gcc/cp/ChangeLog:

            * method.c (genericize_spaceship): Use fold_build2 for scalar
            operands.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/spaceship-fallback1.C: New test.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/100367] [11/12 Regression] Internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators
  2021-05-01  2:51 [Bug c++/100367] New: g++ internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators gccbugzilla at thepirate42 dot org
                   ` (3 preceding siblings ...)
  2021-05-19 20:17 ` cvs-commit at gcc dot gnu.org
@ 2021-05-19 20:18 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2021-05-19 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11.2/12.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-19 20:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-01  2:51 [Bug c++/100367] New: g++ internal compiler error when std::lexicographical_compare_three_way third and fourth argument are reverse iterators gccbugzilla at thepirate42 dot org
2021-05-03 14:30 ` [Bug c++/100367] [11/12 Regression] Internal " ppalka at gcc dot gnu.org
2021-05-18 16:21 ` jason at gcc dot gnu.org
2021-05-19 20:17 ` cvs-commit at gcc dot gnu.org
2021-05-19 20:17 ` cvs-commit at gcc dot gnu.org
2021-05-19 20:18 ` jason at gcc dot gnu.org

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).