I was reading some material about errors that should be avoided when writing C programs and I came across the following code:
#include <stdio.h>
void foo(int param)
{
printf("foo is called\n");
printf("%d\n",param);
}
int main()
{
return foo,(1);
}
The code above build without errors and warnings (it only show a warning when -Wall is activated) but when I run the small program nothing is displayed. The function foo is not called because of the comma separator.
My question is why the C standard allow such syntax? Shouldn't the compiler issue an error in this case? In which context this syntax could be used in some real use case?
Thanks in advance,
PD: I'm using GCC 4.8.3
EDIT:
Couldn't the compiler in this case detect the situation and issue an error instead of warning (as I said it only appears when -Wall is enabled)