3 ms·
I agree, but that is not the most compelling example to be honest. I think a better one is my nemesis: int foo() {} This is not an error or even a warning b
by IshKebab 3y ago
I agree, but that is not the most compelling example to be honest. I think a better one is my nemesis:
int foo() {}
This is not an error or even a warning by default! Worse, even if you have enabled warnings, it can cause stack corruption and crazy insane behaviour in a different file. I've lost hours to this because I was working on code without `-Werror`, I didn't see the warning, and incremental compilation meant the offending file was never recompiled (I was trying to fix the error in a different file).
Of course modern languages don't have this insanity.
- LoganDark 3y agoCould this explain the miscompilation I was experiencing on macOS some years ago where I forgot a `return` statement, the compiler didn't give a single fuck and spit out an executable anyway, and I spent hours in a debugger wondering how the hell I found myself in random completely invalid instructions for no reason? Took hours, perhaps even days to track down. I did it by spamming single-step until it stopped being able to find the line that was currently executing.
- deleted 3y ago[deleted]
- flohofwoe 3y ago> This is not an error or even a warning by default! It depends on the compiler, for instance in Clang this is part of the default warning set: https://www.godbolt.org/z/bKnq456eK https://www.godbolt.org/z/bKnq456eK
- vbezhenar 3y agogcc has that warning as well (not enabled by default, but enabled with -Wall). However gcc does not have a warning that I'm supposed to write `int foo(void){}` (if we're talking about C) which is real issue.
- astrange 3y agoNot true anymore in C2x, () means (void) now. The missing return type is still an issue though.
- flohofwoe 3y agoAh right. Clang will warn if you actually try to call such a () function with arguments: https://www.godbolt.org/z/qEa55PdG9 https://www.godbolt.org/z/qEa55PdG9 Both GCC and MSVC don't care though.