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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.dg/] [tc1/] [dr185.C] - Blame information for rev 149

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

Line No. Rev Author Line
1 149 jeremybenn
// { dg-do run }
2
// Origin: Giovanni Bajo 
3
// DR185: "Named" temporaries and copy elision
4
 
5
extern "C" void abort(void);
6
 
7
struct A {
8
  mutable int value;
9
  explicit A(int i) : value(i) {}
10
  void mutate(int i) const { value = i; }
11
};
12
 
13
int foo() {
14
  A const& t = A(1);
15
  A n(t);          // can this copy be elided? NO!
16
  t.mutate(2);
17
  return n.value;  // can this return 2? NO!
18
}
19
 
20
int main()
21
{
22
  int x = foo();
23
  if (x != 1)
24
    abort();
25
  return 0;
26
}

powered by: WebSVN 2.1.0

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