Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

teddy: always initialize variable #313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rojkov
Copy link

@rojkov rojkov commented May 17, 2021

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.

Hyperscan fails to build with Clang when the "sometimes-unitialized"
check is 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.

Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant