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

            Bug ID: 127007
           Summary: ICE in diagnose_uncaught_exception, at cp/constexpr.cc
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: s.kimura.h41104 at gmail dot com
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/b73M6n36c

Reproducer:
```
struct S {
  constexpr S() {}
  constexpr S(const S &x) {}
  int *s;
};

struct T : S {
  constexpr T(int x) {}
};

template <typename X> constexpr int foo(X x) { throw x; };

static_assert(foo(T(42)));
```

Backtrace:
<source>:13:18: error: non-constant condition for static assertion
   13 | static_assert(foo(T(42)));
      |               ~~~^~~~~~~
<source>:13:18: error: the content of uninitialized storage is not usable in a
constant expression
<source>:11:48: note: allocated here
   11 | template <typename X> constexpr int foo(X x) { throw x; };
      |                                                ^~~~~~~
<source>:13:18: internal compiler error: in diagnose_uncaught_exception, at
cp/constexpr.cc:1792
   13 | static_assert(foo(T(42)));
      |               ~~~^~~~~~~
0x2bef9d8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2be461b internal_error(char const*, ...)
        ???:0
0xb48aa4 fancy_abort(char const*, int, char const*)
        ???:0
0xbc91e3 cxx_constant_value(tree_node*, tree_node*, int)
        ???:0
0xe4ca5a finish_static_assert(tree_node*, tree_node*, unsigned long, bool,
bool, bool)
        ???:0
0xd9f393 c_parse_file()
        ???:0
0xf32999 c_common_parse_file()
        ???:0


This ICE goes back to gcc-16:
https://godbolt.org/z/h9sTsY88K

Reply via email to