-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
clang incorrectly considers top-level cv-qualifiers when determining the parameter mapping for subsumption #75404
Comments
@llvm/issue-subscribers-clang-frontend Author: Casey Carter (CaseyCarter)
Clang considers overload resolution for `f(42)` in this program to be ambiguous:
```c++
template <class> concept True = true;
template <class T> constexpr bool f(const T) { return false;}
template <True T> constexpr bool f(T) { return true; }
static_assert(f(42));
```
which I believe is (or at least should be - the wording around parameter mappings is a bit sparse) non-conforming. Top-level cv-qualifiers on function parameters in C++ should have no effect outside the body of the function definition. This behavior notably diverges from GCC and MSVC (https://godbolt.org/z/jhvnsf8nf).
|
@llvm/issue-subscribers-bug Author: Casey Carter (CaseyCarter)
Clang considers overload resolution for `f(42)` in this program to be ambiguous:
```c++
template <class> concept True = true;
template <class T> constexpr bool f(const T) { return false;}
template <True T> constexpr bool f(T) { return true; }
static_assert(f(42));
```
which I believe is (or at least should be - the wording around parameter mappings is a bit sparse) non-conforming. Top-level cv-qualifiers on function parameters in C++ should have no effect outside the body of the function definition. This behavior notably diverges from GCC and MSVC (https://godbolt.org/z/jhvnsf8nf).
|
@llvm/issue-subscribers-c-20 Author: Casey Carter (CaseyCarter)
Clang considers overload resolution for `f(42)` in this program to be ambiguous:
```c++
template <class> concept True = true;
template <class T> constexpr bool f(const T) { return false;}
template <True T> constexpr bool f(T) { return true; }
static_assert(f(42));
```
which I believe is (or at least should be - the wording around parameter mappings is a bit sparse) non-conforming. Top-level cv-qualifiers on function parameters in C++ should have no effect outside the body of the function definition. This behavior notably diverges from GCC and MSVC (https://godbolt.org/z/jhvnsf8nf).
|
llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp Lines 5602 to 5605 in b45de48
Perhaps this should be |
…ial orderings This fixes a regression since llvm@340eac0, from which we compared function parameter types with cv-qualifiers taken into account. However, as per [dcl.fct]/p5: > After producing the list of parameter types, any top-level cv-qualifiers modifying > a parameter type are deleted when forming the function type. Thus I think we should use hasSameUnqualifiedType for type comparison. This fixes llvm#75404.
For posterity: CWG 1001 says that I'm wrong about this particular case, and that top-level |
Thank you for following up. I'll reopen the issue and see if I can fix that later. |
(Considering that CWG 1001 has been open for over ~15 years, I think we should probably not revert PR #81449 until that issue gets fully resolved.) |
Oops, sorry about this. My private fork accidentally closed this. |
Clang considers overload resolution for
f(42)
in this program to be ambiguous:which I believe is (or at least should be - the wording around parameter mappings is a bit sparse) non-conforming. Top-level cv-qualifiers on function parameters in C++ should have no effect outside the body of the function definition. This behavior notably diverges from GCC and MSVC (https://godbolt.org/z/jhvnsf8nf).
The text was updated successfully, but these errors were encountered: