Re: RFC: Enabling -Wshadow, by default?

Sune Vuorela <[email protected]>
Newsgroups gmane.comp.kde.devel.general
Organization pusling.com internet technologies
Message-ID <[email protected]>
On 2025-12-29, Friedrich W. H. Kossebau <[email protected]> wrote:
> --- 8< ---
>
> Now, fixing those warnings one finds there are some cases where the 
> shadowing might not really be a critical issue. E.g. names of local helper 
> variables which are later reused in another deeper scope, with little chance 
> to get this wrong:
> --- 8< ---
>     [...]
>     auto it = something();
>     if (it) 
>     [...]
>     for (...) {
>        [...]
>        auto it = somethingelse();
>        if (it)
>        [...]
>     }
> --- 8< ---

cppcheck also have warnings for that.

There is also the 

QString Foo::name() const {
   return {};
}

void Foo::someFunction() {
    QString name = name();
    ....
}

That we have in quite many places (cppcheck also warns by default on
these)

I have been slowly cleaning some of it up, but it is quite some work
too.

/Sune
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.