Skip to content
/ server Public

Commit 5688678

Browse files
committed
MDEV-37615: Clang based static analysis false postive reports on UNINIT_VAR
Clang upstream bug llvm/llvm-project#173210 shows that a "int x=x" construct will in the intermediate representation have code to read from x. With this generated sanitizer=undefined and static analyzers will all see the uninitialized read and write. Because clang has a stronger implementation of following paths to uninitialized variables, "#define UNINIT_VAR(x) x" is the which is what our release binaries use is the ideal path for this compiler. Clang based compilers with error during compilation if any uninitialized behaviour is detected at compile time because of 0c80ddb. Corrects MDEV-36542 - 6fd57f4.
1 parent 4b81180 commit 5688678

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

include/my_global.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,10 @@ extern "C" int madvise(void *addr, size_t len, int behav);
444444
/*
445445
Suppress uninitialized variable warning without generating code.
446446
*/
447-
#if defined(__GNUC__) && !defined(WITH_UBSAN)
447+
#if defined(__GNUC__) && !defined(__clang__)
448448
/*
449449
GCC specific self-initialization which inhibits the warning.
450-
clang and static analysis will complain loudly about this
451-
so compile those under WITH_UBSAN.
450+
clang and static analysis will complain loudly about this.
452451
*/
453452
#define UNINIT_VAR(x) x= x
454453
#elif defined(FORCE_INIT_OF_VARS)

0 commit comments

Comments
 (0)