view gcc/testsuite/g++.dg/init/array12.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++/12253
// Bug: We were failing to destroy the temporary A passed to the
// constructor for b[0] before going on to construct b[1].

// { dg-do run }

extern "C" int printf (const char *, ...);

int c;
int r;

struct A
{
  A() { printf ("A()\n"); if (c++) r = 1; }
  A(const A&) { printf ("A(const A&)\n"); ++c; }
  ~A() { printf ("~A()\n"); --c; }
};
 
struct B
{
  B(int, const A& = A()) { printf ("B()\n"); }
};
 
int main()
{
  B b[] = { 0, 0 };
  return r;
}