First of all, gcc is not a compatible C compiler by default. It implements the C89 / C90 dialect with GNU extensions.
You can use -std=cNN -pedantic (where NN can be 90 , 99 or 11 ) to force (try) to match the specified version of the ISO standard. C90 implicit int allowed; It was reset on the C99.
But C compilers do not really need to generate fatal error messages (with the exception of the #error directive). Standard requirement ( N1570 5.1.1.3p1):
The corresponding implementation must give at least one diagnostic message (defined according to the implementation) if the translation unit for preprocessing or the translation unit violates any syntax rule or restriction, even if the behavior is also explicitly specified as undefined or determined by the implementation. Diagnostic messages should not occur under other circumstances.
Non-fatal warning qualifies as a "diagnostic message." The corresponding C compiler can print a warning for any error - even a syntax error - and then continue to successfully compile the source file. (Here's how some language extensions for the compiler can be supported.)
Personally, I find gcc too weak due to certain errors; in my opinion, the lack of int should be seen as a fatal error. But this is only my preference, and not the requirement imposed by the standard.
The lesson here is that you should not allow simple warnings to be harmless. Ideally, code compilation should not produce any diagnostics. Cases where it is normal to ignore warnings are rare (but they exist because compilers can warn about perfectly correct code).
source share