News for hackers. Stuff that matters.
Re:Demystifying bitwise operations, a gentle C tutorial by zoomablemind on Friday March 03, 2023 @01:50PM (#35013517)

       tx_data[44] = utime>16;
Good catch!

I wonder if this would have been flagged with -Wall?

Re:Demystifying bitwise operations, a gentle C tutorial by edflsafoiewq on Friday March 03, 2023 @02:08PM (#35013705)
Nope. There's no warning for bool->int conversion: https://stackoverflow.com/questions/28716391/gcc-forbid-impl...
Re:Demystifying bitwise operations, a gentle C tutorial by HarHarVeryFunny on Friday March 03, 2023 @03:29PM (#35014607)
Somewhat 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.
Re:Demystifying bitwise operations, a gentle C tutorial by zh3 on Friday March 03, 2023 @02:10PM (#35013720)
Nope, 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.

Re:Demystifying bitwise operations, a gentle C tutorial by JohnFen on Friday March 03, 2023 @04:06PM (#35014980)
All 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.

Re:Demystifying bitwise operations, a gentle C tutorial by markrages on Friday March 03, 2023 @06:42PM (#35016507)
Remember -Wall isn't all. -Wall -Wextra is the new -Wall.

I recommend asan too, where possible.

Re:Demystifying bitwise operations, a gentle C tutorial by JohnFen on Friday March 03, 2023 @07:27PM (#35016847)
Oh, you're right. I need to update my build system.
Re:Demystifying bitwise operations, a gentle C tutorial by PokestarFan on Saturday March 04, 2023 @01:14PM (#35023011)
Why do compilers do stupid things like this? Seriously don't get why -Wall isn't all warnings.
Re:Demystifying bitwise operations, a gentle C tutorial by kps on Friday March 03, 2023 @03:32PM (#35014635)
clang-tidy has an open issue to catch this. https://github.com/llvm/llvm-project/issues/56009