Peter Maydell <peter.mayd...@linaro.org> writes: > On Wed, 23 Aug 2023 at 06:59, Markus Armbruster <arm...@redhat.com> wrote: >> >> Peter Maydell <peter.mayd...@linaro.org> writes: >> >> > On Tue, 22 Aug 2023 at 16:50, Alex Bennée <alex.ben...@linaro.org> wrote: >> >> I've already wasted enough of my time debugging aliased variables in >> >> deeply nested loops. >> > >> > In theory we could try to enable -Wshadow and deal with >> > all the existing cases of aliasing, which would then >> > allow us to turn it into an error and catch your bugs :-) >> >> In practice, a quick compile with -Wshadow -Wno-error=shadow coughs up >> almost 6000 warnings. There are duplicates since we compile many files >> multiple times, so I piped through sort -u | wc -l, and got about 1200. > > -Wshadow=local has only 211 non-duplicate warnings, which > is almost tractable... > > (A lot of the duplicates are from local variables declared in macros > like MAX(), MIN() and QOBJECT(), when those macros are used in a nested > way, like MIN(MIN(x,y),z). We could deal with those by using the > __COUNTER__ trick, I guess.)
Oooh, preprocessor trickery! I posted "[PATCH 0/7] Steps towards enabling -Wshadow=local". Need help to get the job finished.