[Bug c++/94041] [10 Regression] temporary object destructor called before the end of the full-expression since r10-5577
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 5 10:25:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94041
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
You were faster.
I came up with:
struct T { T (); ~T (); static int t; };
int T::t = 0;
struct A { A () noexcept; A (const T &) noexcept; const T *a; };
struct B { ~B (); };
struct Pair { A a; B b; };
T::T ()
{
t++;
}
T::~T ()
{
t--;
}
A::A () noexcept : a (nullptr)
{
}
A::A (const T &t) noexcept : a (&t)
{
}
B::~B ()
{
}
T
baz () noexcept
{
return T ();
}
void
foo (const Pair &p) noexcept
{
if (T::t == 0)
__builtin_abort ();
}
void
bar (const Pair& p) noexcept
{
foo ({A (baz ()), p.b});
}
int
main ()
{
Pair p;
bar (p);
}
More information about the Gcc-bugs
mailing list