The following is my demo.c file:
main;
On compiling this gcc gives a warning:
demo.c:1:1: warning: data definition has no type or storage class [enabled by default]
Running ./a.out gives a Segmentation Fault:
Segmentation fault (core dumped)
Is it because, (1) main is not defined anywhere and we are trying to execute it and (2) we are using an imperative statement outside any function, so it can't execute.
In either case, I still don't understand why it should throw a segfault.
Update: It might look similar to Is ‘int main;’ a valid C/C++ program?, but this is different, as not using any identifier, compiles the code.