Browse Source

CheckStructHasMember: fix null deref warning (#15413)

Clang Static Analyzer is so smart that it reports a defect when this
intended null-deref is encountered.  Use sizeof instead which has no
runtime effects.
Peter Wu 11 years ago
parent
commit
e1da4dc2dd
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Modules/CheckStructHasMember.cmake

+ 1 - 1
Modules/CheckStructHasMember.cmake

@@ -69,7 +69,7 @@ macro (CHECK_STRUCT_HAS_MEMBER _STRUCT _MEMBER _HEADER _RESULT)
 ${_INCLUDE_FILES}
 ${_INCLUDE_FILES}
 int main()
 int main()
 {
 {
-   (void)((${_STRUCT} *)0)->${_MEMBER};
+   (void)sizeof(((${_STRUCT} *)0)->${_MEMBER});
    return 0;
    return 0;
 }
 }
 ")
 ")