File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,11 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) {
151
151
152
152
// Implicitly convert lvalue to rvalue, if requested.
153
153
if (ConvertResultToRValue) {
154
+ // Never allow reading from a non-const pointer, unless the memory
155
+ // has been created in this evaluation.
156
+ if (!Ptr.isConst () && Ptr.block ()->getEvalID () != Ctx.getEvalID ())
157
+ return false ;
158
+
154
159
if (std::optional<APValue> V = Ptr.toRValue (Ctx)) {
155
160
EvalResult.setValue (*V);
156
161
} else {
Original file line number Diff line number Diff line change @@ -90,3 +90,12 @@ struct R { mutable long x; };
90
90
struct Z2 { const R &x, y; };
91
91
Z2 z2 = { R{1 }, z2.x .x = 10 };
92
92
93
+ // CHECK: __cxa_atexit({{.*}} @_ZN1BD1Ev, {{.*}} @b
94
+
95
+ // CHECK: define
96
+ // CHECK-NOT: @_ZGRN21ModifyStaticTemporary1cE_
97
+ // CHECK: store {{.*}} @_ZGRN21ModifyStaticTemporary1cE_, {{.*}} @_ZN21ModifyStaticTemporary1cE
98
+ // CHECK: add
99
+ // CHECK: store
100
+ // CHECK: load {{.*}} @_ZN21ModifyStaticTemporary1bE
101
+ // CHECK: store {{.*}} @_ZN21ModifyStaticTemporary1cE
You can’t perform that action at this time.
0 commit comments