4 ms·
tx_data[44] = utime>16; Good catch! I wonder if this would have been flagged with -Wall?
by zoomablemind 4y ago
tx_data[44] = utime>16;
Good catch!
I wonder if this would have been flagged with -Wall?
- edflsafoiewq 4y agoNope. There's no warning for bool->int conversion: https://stackoverflow.com/questions/28716391/gcc-forbid-implicit-bool-int-conversion https://stackoverflow.com/questions/28716391/gcc-forbid-impl...
- HarHarVeryFunny 4y agoSomewhat oddly even in C++, where bool is a distinct type, g++ doesn't have any warning for implicit bool to int conversion, although clang's clang-tidy "linter" tool does.
- zh3 4y agoNope, code was clean with -Wall on arm-9 compiler (i.e. gcc). Interesting thought now you say that (no warning) - only found it because of seeing the pattern (apropos the article) and from that having a good idea what was causing it (knowing the int was assembled a byte at a time). If I had a criticism of modern compilers, it's the blizzard of uninteresting warnings ("strncmp takes const char star, did you really mean to pass it unsigned char star") that make people want to not use -Wall.
- JohnFen 4y agoAll warnings are uninteresting until they're not. > ("strncmp takes const char star, did you really mean to pass it unsigned char star") This warning (with a different function) actually saved my bacon once, pointing me to a very obscure bug in the code. My practice is to use -Wall and make sure that the code compiles without any warnings at all. Then I don't have a deluge of warnings to wade through.
- markrages 4y agoRemember -Wall isn't all. -Wall -Wextra is the new -Wall. I recommend asan too, where possible.
- JohnFen 4y agoOh, you're right. I need to update my build system.
- PokestarFan 4y agoWhy do compilers do stupid things like this? Seriously don't get why -Wall isn't all warnings.
- kps 4y agoclang-tidy has an open issue to catch this. https://github.com/llvm/llvm-project/issues/56009 https://github.com/llvm/llvm-project/issues/56009