Skip to content

Commit 52bf531

Browse files
authored
[Clang][Sema] Fix out-of-bounds access (#80978)
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.
1 parent c76b0eb commit 52bf531

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

clang/docs/ReleaseNotes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ Bug Fixes to C++ Support
208208
parameter where we did an incorrect specialization of the initialization of
209209
the default parameter.
210210
Fixes (`#68490 <https://github.com/llvm/llvm-project/issues/68490>`_)
211+
- Fix a crash when trying to call a varargs function that also has an explicit object parameter.
212+
Fixes (`#80971 ICE when explicit object parameter be a function parameter pack`)
211213

212214
Bug Fixes to AST Handling
213215
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaOverload.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7722,8 +7722,8 @@ bool Sema::CheckNonDependentConversions(
77227722
unsigned Offset =
77237723
Method && Method->hasCXXExplicitFunctionObjectParameter() ? 1 : 0;
77247724

7725-
for (unsigned I = 0, N = std::min(ParamTypes.size(), Args.size()); I != N;
7726-
++I) {
7725+
for (unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
7726+
I != N; ++I) {
77277727
QualType ParamType = ParamTypes[I + Offset];
77287728
if (!ParamType->isDependentType()) {
77297729
unsigned ConvIdx;

clang/test/SemaCXX/cxx2b-deducing-this.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -636,3 +636,13 @@ struct D {
636636
}
637637
};
638638
}
639+
640+
namespace GH80971 {
641+
struct S {
642+
auto f(this auto self...) { }
643+
};
644+
645+
int bug() {
646+
S{}.f(0);
647+
}
648+
}

0 commit comments

Comments
 (0)