-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Clang][Sema] Fix out-of-bounds access #80978
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
Conversation
@llvm/pr-subscribers-clang Author: None (Sirraide) ChangesTrying to compile a C-style variadic member function with an explicit object parameter was crashing in Sema because of an out-of-bounds access. This fixes #80971. Full diff: https://github.com/llvm/llvm-project/pull/80978.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 6a04d68b4f0414..fc3d7d8dcf16e8 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7719,7 +7719,7 @@ bool Sema::CheckNonDependentConversions(
unsigned Offset =
Method && Method->hasCXXExplicitFunctionObjectParameter() ? 1 : 0;
- for (unsigned I = 0, N = std::min(ParamTypes.size(), Args.size()); I != N;
+ for (unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size()); I != N;
++I) {
QualType ParamType = ParamTypes[I + Offset];
if (!ParamType->isDependentType()) {
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index aab35828096a8e..670e72944ee82d 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -636,3 +636,13 @@ struct D {
}
};
}
+
+namespace GH80971 {
+struct S {
+ auto f(this auto self...) { }
+};
+
+int bug() {
+ S{}.f(0);
+}
+}
\ No newline at end of file
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
If you’re wondering what the force-pushes are about, first I forgot to run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
I don’t have commit access, so you or someone else would have to merge it |
Trying to compile a C-style variadic member function with an explicit object parameter was crashing in Sema because of an out-of-bounds access.
This fixes #80971.