Skip to content

False positive warning with -Wshadow on parameter names using Deducing This #95707

@exdal

Description

@exdal

On clang-18.1.7, static analyzer warns about method parameter shadowing of a class field that has the same name member variable.

Example:

struct Foo {
    int val;

    void bar(this auto &self, int val) {
        self.val = val;
    }
};

Error message:

// $ clang++ [...] -std=c++23 -O3 -Wshadow
<source>:6:36: warning: declaration shadows a field of 'Foo' [-Wshadow]
    6 |     void bar(this auto &self, int val) {
      |                                    ^
<source>:4:9: note: previous declaration is here
    4 |     int val;
      |         ^
1 warning generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions