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

            Bug ID: 103019
           Summary: ICE on invalid code with template non-type arugment
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

While reducing PR 102990, I accidently reduced such that I got invalid code
with an ICE without an error message.
Reduced testcase all the way:
struct range_t {  double init;  };
template<range_t setup> struct knob_t {
  int value = setup.init;
};
struct Helpers
{
  knob_t<range_t{100}> inputs;
};
template <class T, int N>  auto detect_fields_count_dispatch() noexcept ->
decltype(sizeof(T{}));
int t = detect_fields_count_dispatch<Helpers>();


--- CUT ----
If you fix the code such that detect_fields_count_dispatch has the correct
template arguments (either removing N from the definition or adding ", 1" to
the usage), the ICE goes away.  Also note if you change the type of value to be
a similar type (that is both are integer types or both real types), the ICE
goes away.

Reply via email to