[clang] [Clang][Sema] Fix crash when 'this' is used in a dependent class scope function template specialization that instantiates to a static member function (PR #87541)

Jordan Rupprecht via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 9 18:52:55 PDT 2024


rupprecht wrote:

This commit appears to regress an example like this:

```c++
template <typename T>
struct Foo {
  template <typename X>
  int bar(X x) {
    return 0;
  }

  template <>
  int bar(int x) {
    return bar(5.0);
  }
};

void call() {
  Foo<double> f;
  f.bar(1);
}
```

Used to compile, now results in an error:
```
PR87541.cpp:10:12: error: call to non-static member function without an object argument
   10 |     return bar(5.0);
      |            ^~~
PR87541.cpp:16:5: note: in instantiation of function template specialization 'Foo<double>::bar<int>' requested here
   16 |   f.bar(1);
      |     ^
```

Is that intended?

https://github.com/llvm/llvm-project/pull/87541


More information about the cfe-commits mailing list