https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99859
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Last reconfirmed| |2021-04-01
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
We want testcases in our bugzilla rather than external links.
No need for any headers,
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)
// if (--ptr->count_ == 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_;
}
};
template class intrusive_ptr<Foo>;
constexpr void bar(intrusive_ptr<Foo> a)
{
// if (a.ptr->count_ != 2) throw 1;
}
constexpr bool foo() {
intrusive_ptr a(new Foo());
bar(a);
return true;
}
static_assert(foo());
reproduces too. Wonder if it isn't related to the instantiation of
intrusive_ptr<Foo>::~intrusive_ptr() while constexpr evaluating the static
assert.