Skip to content

Commit 0c80ddb

Browse files
committed
MDEV-36542: apply clang -Werror=uninitialized to catch dubious initializations
clang has rather correct error detection in its implementation of the -Werror=uninitialized* set of C/CXX flags. Use them by default.
1 parent 6fd57f4 commit 0c80ddb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmake/maintainer.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ IF(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS
6868
SET(MY_ERROR_FLAGS ${MY_ERROR_FLAGS} -Wno-error=non-virtual-dtor) # gcc bug 7302
6969
ENDIF()
7070

71+
FOREACH(LANG C CXX)
72+
IF(CMAKE_${LANG}_COMPILER_ID MATCHES "Clang")
73+
MY_CHECK_AND_SET_COMPILER_FLAG(-Werror=uninitialized-explicit-init)
74+
MY_CHECK_AND_SET_COMPILER_FLAG(-Werror=uninitialized-const-reference)
75+
SET(CMAKE_${LANG}_FLAGS "${CMAKE_${LANG}_FLAGS} -Werror=uninitialized")
76+
ENDIF()
77+
ENDFOREACH()
78+
7179
IF(MYSQL_MAINTAINER_MODE MATCHES "OFF|WARN")
7280
RETURN()
7381
ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO")

0 commit comments

Comments
 (0)