diff options
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 3 | ||||
-rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx11.cpp | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 2b585edaf20..adc82bfe0ba 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -4537,6 +4537,9 @@ const AccessKinds CheckMemberCallThisPointerHandler::AccessKind; /// either within its lifetime or in its period of construction or destruction. static bool checkMemberCallThisPointer(EvalInfo &Info, const Expr *E, const LValue &This) { + if (This.Designator.Invalid) + return false; + CompleteObject Obj = findCompleteObject(Info, E, AK_MemberCall, This, QualType()); diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp index c136b4d2693..46a77e1814d 100644 --- a/clang/test/SemaCXX/constant-expression-cxx11.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp @@ -2284,3 +2284,11 @@ namespace PR40430 { }; static_assert(S().foo() == 'f', ""); } + +namespace PR41854 { + struct e { operator int(); }; + struct f { e c; }; + int a; + f &d = reinterpret_cast<f&>(a); + unsigned b = d.c; +} |