This seems to compile and run without warnings using gcc -Wall
(4.9.2)
#include <stdio.h>
int main(int argc, char **argv){
printf("%d\n", argc-1?:42);
return 0;
}
If I run it
- with 0 args (making
argc-1
evaluate tofalse
), it prints42
; - with n>=1 args (making
argc-1
evaluate totrue
), it prints n-1.
Am I right if I assume that x?:y
is in this case equivalent to x?x:y
? Is this standard, expected behaviour, or just a GCC quirk?