[clang] [Clang][Sema] Fix out-of-bounds access (PR #80978)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 7 03:57:32 PST 2024
https://github.com/Sirraide updated https://github.com/llvm/llvm-project/pull/80978
>From 366651f687eb58ab1775e88da55b1489c118e874 Mon Sep 17 00:00:00 2001
From: Sirraide <aeternalmail at gmail.com>
Date: Wed, 7 Feb 2024 12:49:18 +0100
Subject: [PATCH] [Clang][Sema] Fix out-of-bounds access
---
clang/lib/Sema/SemaOverload.cpp | 4 ++--
clang/test/SemaCXX/cxx2b-deducing-this.cpp | 10 ++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 6a04d68b4f041..ebbbdac631ed2 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7719,8 +7719,8 @@ bool Sema::CheckNonDependentConversions(
unsigned Offset =
Method && Method->hasCXXExplicitFunctionObjectParameter() ? 1 : 0;
- for (unsigned I = 0, N = std::min(ParamTypes.size(), Args.size()); I != N;
- ++I) {
+ for (unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
+ I != N; ++I) {
QualType ParamType = ParamTypes[I + Offset];
if (!ParamType->isDependentType()) {
unsigned ConvIdx;
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index aab35828096a8..30131d6adc4db 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);
+}
+}
More information about the cfe-commits
mailing list