llvm-project/clang/test/SemaCXX/null-cast.cpp
Tim Northover 0150333a3c Create valid LValue to represent null pointers in constant exprs
We were leaving the SubobjectDesignator in a surprising situation, where
it was allegedly valid but didn't actually refer to a type. This caused
a crash later on.

This patch fills out the SubobjectDesignator with the pointee type (as
happens in other evaluations of constant pointers) so that we don't
crash later.

llvm-svn: 303957
2017-05-26 02:16:00 +00:00

9 lines
227 B
C++

// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A {};
struct B : virtual A {};
void foo() {
(void)static_cast<A&>(*(B *)0); // expected-warning {{binding dereferenced null pointer to reference has undefined behavior}}
}