// Core 1376 // { dg-options -std=c++0x } extern "C" void abort(); bool x; struct T { ~T() { if (x) abort (); } }; int main() { T&& r = static_cast<T&&>(T()); x = true; }
Confirmed that the testcase aborts when run
Superseded by issue 1299? See http://wg21.link/p0727.
(In reply to ensadc from comment #2) > Superseded by issue 1299? See http://wg21.link/p0727. To clarify for people who don't click on the link, that's C++ Core Issue 1299, not GCC's bug 1299.
(In reply to ensadc from comment #2) > Superseded by issue 1299? See http://wg21.link/p0727. cc-ing Jens from that
Core issue 1299 resolved via http://wg21.link/p0727 does in fact lifetime-extend the temporary in the example. This bug report should therefore be closed without action. (If a test case is missing that lifetime-extension does happen, the example code can have its "abort" condition reversed to suit that purpose.)
I'll add the test.
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:a7698c0e1ecad65b1ab651acc82b34e12c7efd35 commit r11-8022-ga7698c0e1ecad65b1ab651acc82b34e12c7efd35 Author: Marek Polacek <polacek@redhat.com> Date: Tue Apr 6 22:17:33 2021 -0400 c++: Add test for Core issue 1376 [PR52202] As Jens says in the PR, we handle this correctly. gcc/testsuite/ChangeLog: PR c++/52202 * g++.dg/cpp0x/rv-life.C: New test.
Done.