-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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 doesn't recognise friendship in default parameters in C++20+ #83608
Comments
@llvm/issue-subscribers-clang-frontend Author: Christopher Di Bella (cjdb)
This code doesn't compile on Compiler Explorer. Moving the defaulted parameter to the constructor body seems to be okay.
template<class T>
class single;
template<class T, class U>
class check_constructible {
check_constructible() = default;
static_assert(is_constructible_v<T, U>);
template<class X>
friend class single;
};
template<class T>
struct single {
template<class U>
single(U u, check_constructible<T, U> = {})
: x(u)
{}
T x;
};
int main() {
single<int> x(0);
} Diagnostic:
Compiler info:
Both GCC and MSVC accept this code. If it's not conforming, should we accept it as an extension? |
@llvm/issue-subscribers-c-1 Author: Christopher Di Bella (cjdb)
This code doesn't compile on Compiler Explorer. Moving the defaulted parameter to the constructor body seems to be okay.
template<class T>
class single;
template<class T, class U>
class check_constructible {
check_constructible() = default;
static_assert(is_constructible_v<T, U>);
template<class X>
friend class single;
};
template<class T>
struct single {
template<class U>
single(U u, check_constructible<T, U> = {})
: x(u)
{}
T x;
};
int main() {
single<int> x(0);
} Diagnostic:
Compiler info:
Both GCC and MSVC accept this code. If it's not conforming, should we accept it as an extension? |
If I am reading class.access.general p8:
and temp.inst p12:
correctly then clang is not correct. |
I agree with Shafik's analysis. |
@cjdb I have checked the code with clang-trunk and it runs ok. Could you have a double check? |
@jcsxky it reproduces https://godbolt.org/z/dWf54MYq8 |
Hmm, compliant with -std=c++17 |
This code doesn't compile on Compiler Explorer. Moving the defaulted parameter to the constructor body seems to be okay.
Diagnostic:
Compiler info:
Both GCC and MSVC accept this code. If it's not conforming, should we accept it as an extension?
The text was updated successfully, but these errors were encountered: