https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99859
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The instantiation isn't the problem,
template <class T>
struct intrusive_ptr
{
T *ptr = nullptr;
constexpr explicit intrusive_ptr(T* p) : ptr(p) {
++ptr->count_;
}
constexpr ~intrusive_ptr() {
if (ptr->dec() == 0)
delete ptr;
}
constexpr intrusive_ptr(intrusive_ptr const& a) : ptr(a.ptr) {
++ptr->count_;
}
};
struct Foo {
int count_ = 0;
constexpr int dec() {
return --count_;
}
};
constexpr bool baz() {
Foo f { 4 };
intrusive_ptr a(&f);
return true;
}
constexpr bool x = baz();
constexpr void bar(intrusive_ptr<Foo> a)
{
}
constexpr bool foo() {
intrusive_ptr a(new Foo());
bar(a);
return true;
}
static_assert(foo());
fails too, and during the finish_static_assert fold_nondependent_expr
evaluation only one cxx_eval_outermost_expr is called.