-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Incorrect constraint check with template friend function #90349
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
Comments
@llvm/issue-subscribers-clang-frontend Author: Todd Reed (toddreed)
See https://godbolt.org/z/rTcabGbbh. This compiles with GCC 13.2, but with clang 18.1.0.
I’ve tried to reduce this to the smallest program that exhibits the bug, and AFAICT, it relates to a template friend function that has the same template arguments as its enclosing class, but the order of the template arguments are reversed. When instantiating the template function, the compiler seems to apply the wrong constraint checks (C++ concepts) on the template arguments. |
Code: https://godbolt.org/z/qnh6EdGGe Looks like only clang rejects. #include <concepts>
template<std::integral T, std::floating_point Float>
class Blob;
template<std::floating_point Float, std::integral T>
Blob<T, Float> MakeBlob();
template<std::integral T, std::floating_point Float>
class Blob {
private:
Blob() {}
friend Blob<T, Float> MakeBlob<Float, T>();
};
template<std::floating_point Float, std::integral T>
Blob<T, Float> MakeBlob()
{
return Blob<T, Float>();
}
template<std::floating_point Float, std::integral T>
Blob<T, Float> FindBlobs()
{
return MakeBlob<Float, T>();
}
int main(int argc, const char * argv[]) {
FindBlobs<double, int>();
return 0;
} |
@llvm/issue-subscribers-c-20 Author: Todd Reed (toddreed)
See https://godbolt.org/z/rTcabGbbh. This compiles with GCC 13.2, but with clang 18.1.0.
I’ve tried to reduce this to the smallest program that exhibits the bug, and AFAICT, it relates to a template friend function that has the same template arguments as its enclosing class, but the order of the template arguments are reversed. When instantiating the template function, the compiler seems to apply the wrong constraint checks (C++ concepts) on the template arguments. |
Closed via #88963 |
See https://godbolt.org/z/rTcabGbbh. This compiles with GCC 13.2, but with clang 18.1.0.
I’ve tried to reduce this to the smallest program that exhibits the bug, and AFAICT, it relates to a template friend function that has the same template arguments as its enclosing class, but the order of the template arguments are reversed. When instantiating the template function, the compiler seems to apply the wrong constraint checks (C++ concepts) on the template arguments.
The text was updated successfully, but these errors were encountered: