comparison gcc/testsuite/gcc.dg/pr46921.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* PR c/46921 lost side effect when struct initializer expr uses comma
2 operator */
3
4 /* { dg-do run } */
5 /* { dg-options "" } */
6
7 extern int printf(const char *, ...);
8 extern void abort (void);
9
10 typedef struct __uws_0 { } uw_unit;
11 uw_unit uw_unit_v = {};
12
13 struct __uws_1
14 {
15 struct __uws_0 __uwf_1;
16 struct __uws_1* __uwf_2;
17 };
18
19 static int left_hand_eval = 0;
20
21 static void
22 foo (const char *s)
23 {
24 ++left_hand_eval;
25 printf("%s", s);
26 }
27
28 int
29 main ()
30 {
31 struct __uws_1 tmp = {(foo("Inner\n"), uw_unit_v)};
32
33 printf("Outer\n");
34 /* left hand expression in comma operator initializer must always be
35 evaluated if there are side effects. */
36 if (!left_hand_eval)
37 abort ();
38
39 return 0;
40 }