hyperscan icon indicating copy to clipboard operation
hyperscan copied to clipboard

teddy: always initialize variable

Open rojkov opened this issue 4 years ago • 0 comments

Hyperscan fails to build with Clang with the "sometimes-unitialized" check switched on:

src/fdr/teddy_runtime_common.h:359:13: error: variable 'val' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (avail >= 64) {
            ^~~~~~~~~~~
src/fdr/teddy_runtime_common.h:388:27: note: uninitialized use occurs here
    val = loadu_mask_m512(val, j, ptr);
                          ^~~
src/fdr/teddy_runtime_common.h:359:9: note: remove the 'if' if its condition is always true
        if (avail >= 64) {
        ^~~~~~~~~~~~~~~~~
src/fdr/teddy_runtime_common.h:351:5: note: variable 'val' is declared here
    m512 val;
    ^

Always initialize val to zero upon declaration.

NOTE: this PR fixes the build failure only. I don't know if initializing val to zero is harmless.

rojkov avatar May 17 '21 13:05 rojkov