mirror of
https://github.com/intel/llvm.git
synced 2026-01-17 23:25:14 +08:00
[clang][bytecode] Fail on reads from constexpr-unknown pointers (#164996)
If they aren't const. Fixes https://github.com/llvm/llvm-project/issues/164985
This commit is contained in:
@@ -832,6 +832,8 @@ bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
|
||||
return false;
|
||||
if (!CheckVolatile(S, OpPC, Ptr, AK))
|
||||
return false;
|
||||
if (!Ptr.isConst() && !S.inConstantContext() && isConstexprUnknown(Ptr))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
15
clang/test/AST/ByteCode/codegen-cxx20.cpp
Normal file
15
clang/test/AST/ByteCode/codegen-cxx20.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fcxx-exceptions | FileCheck %s
|
||||
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fcxx-exceptions -fexperimental-new-constant-interpreter | FileCheck %s
|
||||
|
||||
|
||||
/// The read from a used to succeed, causing the entire if statement to vanish.
|
||||
extern void e();
|
||||
int somefunc() {
|
||||
auto foo = [a = false]() mutable {
|
||||
if (a)
|
||||
e();
|
||||
};
|
||||
foo();
|
||||
}
|
||||
|
||||
// CHECK: call void @_Z1ev()
|
||||
Reference in New Issue
Block a user