summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/nrv4.C
blob: 531647d67e13460480a36d35e8fa10c603d5062e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// PR optimization/7145
// Bug: The NRV optimization caused us to lose the initializer for 'ret'.
// { dg-options -O }
// { dg-do run }

struct GdkColor {
  long  pixel;
  short red;
  short green;
  short blue;
};

inline GdkColor mkcolor() {
  GdkColor ret={0,1,2,3};
  return ret;
}

int
main()
{
  GdkColor col=mkcolor();
  return (col.pixel != 0 || col.red != 1 || col.green != 2 || col.blue != 3);
}