Q:

issue with the conditional operator

#include<stdio.h>
int main()
{
  printf("%d\n", 4 ?: 8);
}

According to the C standard this program is invalid because it is missing an expression between the ? and :.But The interesting thing is that there is when I compile the code it is printing 4.how come it will print 4 rather than showing any compile error

A:

This is a gcc extension.  
x ? : y

is equivalent to
x ? x : y

See here for detail.

