Skip to content

Commit 7e690db

Browse files
authored
[Clang][NFC] Introduce no local variable to avoid use after move (#139784)
Static analysis flagged the use of Left.size() because we just moved out of Left and that would be undefined behavior. Fix is to take the size and store it in a local variable instead.
1 parent 3302f9f commit 7e690db

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clang/lib/Sema/SemaConcept.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1999,8 +1999,9 @@ FormulaType SubsumptionChecker::Normalize(const NormalizedConstraint &NC) {
19991999
});
20002000

20012001
if (NC.getCompoundKind() == FormulaType::Kind) {
2002+
auto SizeLeft = Left.size();
20022003
Res = std::move(Left);
2003-
Res.reserve(Left.size() + Right.size());
2004+
Res.reserve(SizeLeft + Right.size());
20042005
std::for_each(std::make_move_iterator(Right.begin()),
20052006
std::make_move_iterator(Right.end()), Add);
20062007
return Res;

0 commit comments

Comments
 (0)