Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/opt/flifetime-dse4.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
// { dg-options "-O3 -flifetime-dse=1" } // { dg-do run } // { dg-xfail-run-if "AIX operator new" { powerpc-ibm-aix* } } typedef __SIZE_TYPE__ size_t; inline void * operator new (size_t, void *p) { return p; } struct A { int i; A() {} ~A() {} }; int main() { int ar[1] = { 42 }; A* ap = new(ar) A; // With -flifetime-dse=1 we retain the old value. if (ap->i != 42) __builtin_abort(); ap->i = 42; ap->~A(); // When the destructor ends the object no longer exists. if (ar[0] == 42) __builtin_abort(); }