2 ms·
But there aren't a lot of good reasons to compile with C90 or older these days (for portability you can just restrict yourself to the portable subset). I suspec
by gpderetta 5y ago
But there aren't a lot of good reasons to compile with C90 or older these days (for portability you can just restrict yourself to the portable subset). I suspect the flag is there to support old unmaintained programs and it makes sense not to change their behaviour (because nobody is going to fix bugs in them), as long as it is not a big burden on the compiler. In fact, think of old K&R C instead of C90.
I wouldn't be surprised if there are old unix tools that relied on propagating the result of the last operation executed into main. In fact sometimes gcc has added explicit flags to enable this kind of "traditional" behaviour.
Clang was written well after C99, so it didn't make sense to implement the old traditional behaviour there in the first place.
- kazinator 5y ago> aren't a lot of good reasons to compile with C90 Sure there are, like: - Project doesn't want mixed declarations and statements creeping into the code base - Project doesn't want want variable-length arrays creeping into the code base. - Project doesn't want new footguns in preprocessing. - Project hates mixtures of // and /.../ comments. I think the Linux kernel is still using C90 (with GNU extensions). > tools that relied on propagating the result of the last operation executed into main. In all the situations in which the compiler has enough information to indicate the insert of a "return 0", it could emit a diagnostic (if it is in C90 mode). foo.c:17: warning: main returns without a value [-std=c90, -Wmain-return] The user is alerted to this and can look at the code and decide whether it's just missing a "return last_operation();" or whether it should be "(void) last_operation(); return 0;". -std=c90 is not a good option for requesting "I want the random contents of the return register left behind by the last function called in main to be the return value of main, if possible".