PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / pr46921.c
blob17dfedd7e0a272dcc81666986310efdb0b9bde79
1 /* PR c/46921 lost side effect when struct initializer expr uses comma
2 operator */
4 /* { dg-do run } */
5 /* { dg-options "" } */
7 extern int printf(const char *, ...);
8 extern void abort (void);
10 typedef struct __uws_0 { } uw_unit;
11 uw_unit uw_unit_v = {};
13 struct __uws_1
15 struct __uws_0 __uwf_1;
16 struct __uws_1* __uwf_2;
19 static int left_hand_eval = 0;
21 static void
22 foo (const char *s)
24 ++left_hand_eval;
25 printf("%s", s);
28 int
29 main ()
31 struct __uws_1 tmp = {(foo("Inner\n"), uw_unit_v)};
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 ();
39 return 0;