
Previously we would defer evaluation of CLEs until LValue to RValue conversions, which would result in creating values within wrong scope and triggering use-after-frees. This patch instead eagerly evaluates CLEs, within the scope requiring them. This requires storing an extra pointer for CLE expressions with static storage. Fixes https://github.com/llvm/llvm-project/issues/137165
13 lines
305 B
C++
13 lines
305 B
C++
// Test that we can successfully compile this code, especially under ASAN.
|
|
// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s
|
|
// expected-no-diagnostics
|
|
struct Foo {
|
|
Foo* f;
|
|
operator bool() const { return true; }
|
|
};
|
|
constexpr Foo f((Foo[]){});
|
|
int foo() {
|
|
if (Foo(*f.f)) return 1;
|
|
return 0;
|
|
}
|