Skip to content

[Clang] Confusing mismatch in diagnostics related to explicit this parameters #97878

@nofe1248

Description

@nofe1248

Clang version: x86_64 trunk
Command line options: -std=c++26
Minimal reproduction:

class TestClass {
    void testFunction(this auto&& self, int &&some_rvalue_reference) {}
};

void testDiagnostics(int &&some_rvalue_reference) {
    TestClass test_class;
    test_class.testFunction(some_rvalue_reference); //error, should use std::move
}

On Compiler Explorer

Compiler Output:

...
<source>:2:10: note: candidate function template not viable: expects an rvalue for 1st argument
    2 |     void testFunction(this auto&& self, int &&some_rvalue_reference) {}
      |          ^            ~~~~~~~~~~~~~~~~
...

The underlined parameter should be int &&some_rvalue_reference.

Metadata

Metadata

Assignees

Labels

clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzergood first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions