llvm-project/clang/test/Analysis/Issue56873.cpp
isuckatcs 10a7ee0bac [analyzer] Fix for the crash in #56873
In ExprEngine::bindReturnValue() we cast an SVal to DefinedOrUnknownSVal,
however this SVal can also be Undefined, which leads to an assertion failure.

Fixes: #56873

Differential Revision: https://reviews.llvm.org/D130974
2022-08-03 19:25:02 +02:00

25 lines
471 B
C++

// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
void clang_analyzer_warnIfReached();
struct S {
};
void Issue56873_1() {
int n;
// This line used to crash
S *arr = new S[n];
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
}
void Issue56873_2() {
int n;
// This line used to crash
int *arr = new int[n];
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
}