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) {
152152
153153 // Implicitly convert lvalue to rvalue, if requested.
154154 if (ConvertResultToRValue) {
155+ if (!Ptr.isDereferencable ())
156+ return false ;
155157 // Never allow reading from a non-const pointer, unless the memory
156158 // has been created in this evaluation.
157159 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
88 // both-note {{division by zero}}
99constexpr _Bool inf3 = __builtin_inf () == __builtin_inf ();
1010
11+ /// Used to crash.
12+ struct S {
13+ int x ;
14+ char c ;
15+ float f ;
16+ };
1117
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