6_5_15_01_conditional_comma_in_middle.c (610B)
1 /* §6.5.15 -- the middle operand of the conditional operator is a full 2 * `expression`, which by §6.5.17 includes comma-separated sequences. 3 * `a ? b, c : d` parses as `a ? (b, c) : d`. kit's expression parser 4 * bottoms out at assignment-expression for the middle operand and trips 5 * on the comma with "expected ':' in ternary". Hits stb_image_write.h 6 * via `stbiw__sbfree(a) ((a) ? STBIW_FREE(raw(a)),0 : 0)`. */ 7 static int sink; 8 9 static int f(int side_effect, int result) { 10 sink = side_effect; 11 return result; 12 } 13 14 int test_main(void) { 15 int x = 1 ? f(7, 0), 42 : 99; 16 return (sink == 7) ? x : 0; 17 }