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

            Bug ID: 93664
           Summary: ICE: Segmentation fault on invalid concept code
                    gcc/gcc/cp/constraint.cc:2537
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-bugs at marehr dot dialup.fu-berlin.de
  Target Milestone: ---

Hi gcc-team,

this (invalid!) code ICEs:

```c++
#include <iterator>
#include <utility>

template <typename T>
concept bool semiregular = requires(T t) {
  {(t != t)};
};
template <typename T> concept bool view_ = semiregular<T>;
template <bool B> concept bool is_true = B;

// this part is invalid, commenting in =, or
// ommiting bool resolves the ICE
template <typename T>
concept bool
    pair_like_convertible_from_ /*=*/ (is_true<true>);

template <typename I>
struct subrange {
  template <typename PairLike>
  requires pair_like_convertible_from_<PairLike>
  operator PairLike();
};

int main() {
  subrange<std::istreambuf_iterator<char>> sub;
  view_<decltype(sub)>;
}
```

https://godbolt.org/z/c__ob5

When replacing all `concept bool` with `concept` the ICE vanishes.

```
> g++-git --std=c++2a

ice.cpp: In instantiation of ‘subrange<I>::operator PairLike() [with PairLike =
const std::error_condition; I = std::istreambuf_iterator<char,
std::char_traits<char> >]’:
ice.cpp:6:7:   required from here
ice.cpp:6:7: internal compiler error: Segmentation fault
    6 |   {(t != t)};
      |    ~~~^~~~~
0xc8026f crash_signal
        /home/marehr/Packages/gcc-git/src/gcc/gcc/toplev.c:328
0x69819d force_rvalue(tree_node*, int)
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/cvt.c:564
0x6834c2 satisfy_constraint_r
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/constraint.cc:2537
0x683bf8 satisfy_constraint
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/constraint.cc:2599
0x6845c4 satisfy_declaration_constraints
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/constraint.cc:2617
0x6850e8 constraint_satisfaction_value
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/constraint.cc:2733
0x6850e8 constraints_satisfied_p(tree_node*)
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/constraint.cc:2754
0x6511f2 add_function_candidate
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:2281
0x6537fc add_template_candidate_real
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:3440
0x653d86 add_template_candidate
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:3481
0x653d86 add_candidates
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:5829
0x64f0b5 add_candidates
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:5744
0x64f0b5 build_user_type_conversion_1
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:4079
0x64fb43 reference_binding
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:1843
0x650121 implicit_conversion
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:1992
0x650e79 add_function_candidate
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:2389
0x653dc4 add_candidates
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:5842
0x654357 add_candidates
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:5744
0x654357 add_operator_candidates
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:5933
0x659344 build_new_op_1
        /home/marehr/Packages/gcc-git/src/gcc/gcc/cp/call.c:6156
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.
```

```
> g++-git -v

Using built-in specs.
COLLECT_GCC=g++-git
COLLECT_LTO_WRAPPER=/opt/gcc/gcc-git/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/marehr/Packages/gcc-git/src/gcc/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++ --enable-shared --enable-threads=posix
--with-system-zlib --with-isl --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-lto --enable-plugin --enable-install-libiberty
--with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib
--disable-werror --enable-checking=release --enable-default-pie
--enable-default-ssp --enable-cet=auto --disable-boostrap
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.0.1 20200206 (experimental) (GCC)
```

Reply via email to