Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/gcc.dg/pr46921.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
line wrap: on
line source
/* PR c/46921 lost side effect when struct initializer expr uses comma operator */ /* { dg-do run } */ /* { dg-options "" } */ extern int printf(const char *, ...); extern void abort (void); typedef struct __uws_0 { } uw_unit; uw_unit uw_unit_v = {}; struct __uws_1 { struct __uws_0 __uwf_1; struct __uws_1* __uwf_2; }; static int left_hand_eval = 0; static void foo (const char *s) { ++left_hand_eval; printf("%s", s); } int main () { struct __uws_1 tmp = {(foo("Inner\n"), uw_unit_v)}; printf("Outer\n"); /* left hand expression in comma operator initializer must always be evaluated if there are side effects. */ if (!left_hand_eval) abort (); return 0; }