-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static and non-static member function templates with the same parameter types are accepted #52951
Comments
@llvm/issue-subscribers-c-20
This code
```
struct A {
static int f(auto) { return 1; }
int f(auto) requires true { return 2; }
};
```
is invalid per https://timsong-cpp.github.io/cppwp/n4861/class.static.mfct#2:
> There shall not be a static and a non-static member function with the same name and the same parameter types ([over.load]).
But Clang accepts it without a warning (as some other compilers do), which later produces confusing errors. Related discussion: https://stackoverflow.com/q/70542265/7325599 |
@llvm/issue-subscribers-clang-frontend
This code
```
struct A {
static int f(auto) { return 1; }
int f(auto) requires true { return 2; }
};
```
is invalid per https://timsong-cpp.github.io/cppwp/n4861/class.static.mfct#2:
> There shall not be a static and a non-static member function with the same name and the same parameter types ([over.load]).
But Clang accepts it without a warning (as some other compilers do), which later produces confusing errors. Related discussion: https://stackoverflow.com/q/70542265/7325599 |
Referenced note was modified to exclude quoted sentence in P1787R6 Declarations and where to find them. I'm not sure what is the normative wording for this. |
Not a bug Two function or function template declarations declare corresponding overloads if:
@Endilll is correct this was changed by P1787, and a whole bunch of subsequent papers pertaining to Removing the require makes the definition correspond https://compiler-explorer.com/z/sY6hdTzoK |
So this related code definitely shows an issue: https://gcc.godbolt.org/z/aYK8Y31d4 struct A {
static int f(auto) { return 1; }
int f(auto) requires true { return 2; }
};
int main() {
[[maybe_unused]] int (A::*y)(int) = &A::f; // ok everywhere (if no below line)
[[maybe_unused]] int (*x)(int) = &A::f; //ok in GCC and Clang (if no above line)
} but I believe this would then be: #49884 |
CC @zygoloid @hubert-reinterpretcast should this example I posted just before this be ambiguous? After reading expr.unary p6 and over.over p6 I think this should be valid but wanted confirmation. |
@shafik I believe that case is https://eel.is/c++draft/over.over#4 specifically
|
Fixed in trunk by 4b163e3. |
This code
is invalid per https://timsong-cpp.github.io/cppwp/n4861/class.static.mfct#2:
But Clang accepts it without a warning (as some other compilers do), which later produces confusing errors. Related discussion: https://stackoverflow.com/q/70542265/7325599
The text was updated successfully, but these errors were encountered: