llvm / llvm/llvm-project

Address of an overloaded template method as a function call argument

Open
#167,493 2 comments 0 reactions 0 assignees View on GitHub
clang:frontend diverges-from:gcc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The following piece of code doesn't compile with Clang (21.1.0) while compiling well with GCC (15.2) ([see here](https://compiler-explorer.com/z/qncsqbjdr)):
```c++
struct S {
template
void f() const& {}
template
void f() & {}
template
void f() && {}
};

template
void g(R(Class::*property)() const&) {}

template
void g(R(Class::*property)() const) {}

int main() {
g(&S::f);
}
```
I think Clang either skips entirely or does poor job at the "template argument deduction" stage of [function selection](https://en.cppreference.com/w/cpp/language/overloaded_address.html#Selecting_functions)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the provided C++ example in the linked Compiler Explorer case with Clang 21.1.0 and GCC 15.2, then trace Clang's handling of overloaded function-address selection and template argument deduction. Done means Clang accepts the example consistently and its behavior matches the standard and GCC.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.