1 // { dg-do run } 2 // { dg-options "-felide-constructors" } 3 // GROUPS passed temps 4 // temps file 5 // Message-Id: <9311102043.AA22871@ses.com> 6 // From: jamshid@ses.com (Jamshid Afshar) 7 // Subject: elide-constructors (aka return value optimization) 8 // Date: Wed, 10 Nov 93 14:43:54 CST 9 10 #include <stdio.h> 11 #include <stdlib.h> 12 13 class X { 14 int i; 15 public: 16 X(); 17 X(const X&); 18 X(int); 19 ~X(); 20 }; 21 22 int did_it = 0; 23 X()24X::X() { ; } X(const X &)25X::X(const X&) { did_it = 1; } X(int)26X::X(int) { ; } ~X()27X::~X() { ; } 28 foo()29X foo() { 30 X x(1); 31 return x; 32 } 33 34 int main()35main() { 36 X x = foo(); 37 if (did_it) 38 abort (); 39 else 40 printf ("PASS\n"); 41 42 return 0; 43 } 44