Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
p100sch15004yThat was unfortunate, but don't forget that the devrant tag is only for devrant related topics not Dev rants.
-
GCC 6 and later warns about misleading indentation when using -Wall, but unfortunately, that does not work in this specific case. I've just tested it.
In the "forgotten semicolon" version, the statement after the while has the same indentation as the while because it wasn't meant to be in the while scope, but no warning. -
@NeoSama Holy shit, not even Clang 10 with -Wall -Wextra -Wpedantic finds that, and neither CppCheck. Good to know that this kind of bug needs manual attention.
Related Rants
While coding in C, I once forgot to add a semicolon at the end of a while loop polling a register value.
The logic required me to make it zero as soon as it read non-zero and continue the rest of the process. Hence the 'while' that missed the semicolon ended up being a single instruction assignment to the same volatile register that I kept polling. This caused synchronisation issue with the FPGA, and my code got stuck in an uncertain infinite loop.
Took me 2 days and a silly, yet valid question from my teammate to figure out the cause of this stupid bug.
devrant
embedded
wk219
c