File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,8 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) {
152
152
153
153
// Implicitly convert lvalue to rvalue, if requested.
154
154
if (ConvertResultToRValue) {
155
+ if (!Ptr.isDereferencable ())
156
+ return false ;
155
157
// Never allow reading from a non-const pointer, unless the memory
156
158
// has been created in this evaluation.
157
159
if (!Ptr.isConst () && Ptr.block ()->getEvalID () != Ctx.getEvalID ())
Original file line number Diff line number Diff line change @@ -8,4 +8,17 @@ constexpr _Bool inf2 = (1.0/0.0 == __builtin_inf()); // both-error {{must be ini
8
8
// both-note {{division by zero}}
9
9
constexpr _Bool inf3 = __builtin_inf () == __builtin_inf ();
10
10
11
+ /// Used to crash.
12
+ struct S {
13
+ int x ;
14
+ char c ;
15
+ float f ;
16
+ };
11
17
18
+ #define DECL_BUFFER (Ty , Name ) alignas(Ty) unsigned char Name[sizeof(Ty)]
19
+
20
+ char bar () {
21
+ DECL_BUFFER (struct S , buffer );
22
+ ((struct S * )buffer )-> c = 'a' ;
23
+ return ((struct S * )buffer )-> c ;
24
+ }
You can’t perform that action at this time.
0 commit comments