blob: d0170cd18f6765431422533b1edbb17d962b90f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Submitted by Erik Rozendaal <dlr@acm.org>
// Test case for GNATS bug 787.
// { dg-do run }
#include <stdio.h>
#include <stdlib.h>
static int calls;
int &foo (int &arg)
{
calls++;
arg=0;
return arg;
}
int &identity (int &x)
{
return x;
}
int main()
{
int a;
calls = 0;
int &b = ++foo (a);
if (calls > 1)
abort ();
if (&a != &b)
abort ();
if (a != 1)
abort ();
calls = 0;
int &c = ++identity (++foo (a));
if (calls > 1)
abort ();
if (&a != &c)
abort ();
if (a != 2)
abort ();
exit (0);
}
|