view gcc/testsuite/g++.dg/init/elide5.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

// PR c++/71913
// { dg-do link { target c++11 } }

void* operator new(decltype(sizeof(1)), void* p) { return p; }

struct IndirectReturn {
  IndirectReturn() {}
  // Undefined so we get a link error if the indirect return value is copied
  IndirectReturn(const IndirectReturn&);
  IndirectReturn& operator=(const IndirectReturn&) = delete;
  ~IndirectReturn() {}
};

IndirectReturn foo() { return IndirectReturn(); }

void bar(void* ptr) {
  new (ptr) IndirectReturn(foo());
}

alignas (alignof (IndirectReturn))
unsigned char c[sizeof(IndirectReturn)];

int main()
{
  bar(c);
}