OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [init/] [elide1.C] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// { dg-do run }
2
 
3
// Test that the destructor for a temporary passed by value isn't run
4
// until end of full-expression, as per [class.copy]:
5
 
6
// Whenever a temporary class object is copied using a copy  constructor,
7
// and  this  object  and  the copy have the same cv-unqualified type, an
8
// implementation is permitted to treat the original and the copy as  two
9
// different  ways of referring to the same object and not perform a copy
10
// at all, even if the class copy constructor  or  destructor  have  side
11
// effects....                                       In these cases,  the
12
// object  is  destroyed  at the later of times when the original and the
13
// copy would have been destroyed without the optimization.
14
 
15
// Here, the temporary would be destroyed later than the parm, so either we
16
// must suppress the optimization in this case or destroy value parms in the
17
// caller.
18
 
19
int d;
20
 
21
struct A {
22
  A () { }
23
  A (const A&) { }
24
  ~A() { ++d; }
25
};
26
 
27
void f (A a) { }
28
 
29
int main ()
30
{
31
  int r;
32
  f (A ()), r = d;
33
 
34
  if (r < d && d)
35
    return 0;
36
  else
37
    return 1;
38
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.