Index: lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp +++ lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp @@ -44,6 +44,9 @@ if (!ToPTy || !OrigPTy) return; + if (E->IgnoreParenCasts()->getType()->isArrayType()) + return; + QualType OrigPointeeTy = OrigPTy->getPointeeType(); QualType ToPointeeTy = ToPTy->getPointeeType(); Index: test/Analysis/array-struct.c =================================================================== --- test/Analysis/array-struct.c +++ test/Analysis/array-struct.c @@ -176,6 +176,10 @@ } } +void f19() { + int data[10]; + struct s3 *a = (struct s3 *)data; +} // [PR13927] offsetof replacement macro flagged as "dereference of a null pointer" int offset_of_data_array(void) Index: test/Analysis/misc-ps-region-store.m =================================================================== --- test/Analysis/misc-ps-region-store.m +++ test/Analysis/misc-ps-region-store.m @@ -299,7 +299,7 @@ int test_handle_array_wrapper() { struct ArrayWrapper x; test_handle_array_wrapper_helper(&x); - struct WrappedStruct *p = (struct WrappedStruct*) x.y; // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption}} + struct WrappedStruct *p = (struct WrappedStruct*) x.y; return p->z; // no-warning }