Looks like that -Wshadow is so important

For GCC, you can use -Wshadow.

-Wshadow

Warn whenever a local variable or type declaration shadows another variable, parameter, type, or class member (in C++), or whenever a built-in function is shadowed. Note that in C++, the compiler warns if a local variable shadows an explicit typedef, but not if it shadows a struct/class/enum.

By carelessly re-declaring a variable in a while scope, was stuck on a super annoying bug for a ton of time… looks like that -Wshadow is so important.