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

            Bug ID: 110212
           Summary: ICE on invalid: template constraint failure
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stevenxia990430 at gmail dot com
  Target Milestone: ---

The following invalid program produces internal compiler error: error reporting
routines re-entered (related to template constraints). Tested on GCC-trunk.
Apologies that it might be complex, had a difficult time trying to reduce this.

To quickly reproduce: https://gcc.godbolt.org/z/7hxdx6Y6Y
```
#include <array>
#include <iostream>
#include <type_traits>

template<typename T>
struct foo<T, std::void_t<decltype(std::declval<std::ostream&>() <<
std::declval<T>().size())>> : std::true_type {};

template<typename T, typename std::enable_if_t<foo<T>::value>* = nullptr>
auto print_elements(T const& t) -> decltype(std::declval<std::ostream&>() <<
std::declval<T>().size(), void())
{
    std::cout << t;
}

int main()
{
    std::array<int, 10U> a{ 2, 0, 5, 66, 4, 90, 25, 54, 23, 1 };
    print_elements(a);
}
```

Note: requires -std=c++20 and above.
  • [Bug c++/110212] New: ICE on... stevenxia990430 at gmail dot com via Gcc-bugs

Reply via email to