stb
stb copied to clipboard
[Suggestion] stb_vorbis: "declaration shadows a local variable" Clang errors
Describe the bug
There are tons of errors related to declaration shadows a local variable like this one:
error: declaration shadows a local variable [-Werror,-Wshadow] int z = get8_packet_raw(f);
To Reproduce Try to compile stb_vorbis using Clang 3.5 with the "-Wshadow" option.
I know it's easy to fix this by renaming some of the variables (like here)

Why do you call this a bug? Block scope is a legit language feature: https://en.cppreference.com/w/c/language/scope From my perspective, it is your problem that you are using -Werror command line switch.
Why do you call this a bug? Block scope is a legit language feature: https://en.cppreference.com/w/c/language/scope From my perspective, it is your problem that you are using -Werror command line switch.
I know that it is okay in C, but many modern compilers issue this as a warning or an error even without "-Wshadow" option. Remove of shadowing variables would be a silver bullet.
but many modern compilers issue this as a warning or an error even without "-Wshadow" option.
If a compiler is unable to compile valid C code then that compiler is defective and you should file a bug report against it.
Also which "modern compiler" errors on shadowing by default?? That sounds like bullshit.
@N-R-K This is a perfectly reasonable request.
Generally stb libraries try to compile without warnings with any reasonable set of warnings (not -Wall and definitely not -Wextra) to streamline the integration. In this particular cases -Wshadow combined with warnings-as-errors (which is perfectly reasonable to turn on as well) makes the file incompilable. I have no problem with the complaint, and I may fix it at some point and will certainly accept a PR that fixes it.
@N-R-K This is a perfectly reasonable request.
Sure, I didn't mean to come off as dismissive of the issue.
I was more curious about which compiler errors out due to -Wshadow by default. Because that warning is typically something that user needs to explicitly enable since it's stylistic in nature.
I don't know the answer to your question, but it's a known source of bugs (e.g. introducing an inner-scoped variable that's already being used for a different purpose inside the scope), not purely stylistic.