[Nasm-bugs] [Bug 3392466] New: -Wmaybe-uninitialized warning from iflag_set_cpu()

no-reply at bugzilla-nasm.gorcunov.org no-reply at bugzilla-nasm.gorcunov.org
Thu Feb 22 23:28:14 PST 2018


            Bug ID: 3392466
           Summary: -Wmaybe-uninitialized warning from iflag_set_cpu()
           Product: NASM
           Version: 2.14 (development)
          Hardware: All
                OS: All
            Status: OPEN
          Severity: normal
          Priority: Medium
         Component: Assembler
          Assignee: nobody at nasm.us
          Reporter: sezeroz at gmail.com
                CC: gorcunov at gmail.com, hpa at zytor.com, nasm-bugs at nasm.us
     Obtained from: Built from git using configure

My gcc7.3 emits the following:

In file included from asm/assemble.h:42:0,
                 from asm/directiv.c:53:
asm/directiv.c: In function ‘process_directives’:
./include/iflag.h:148:28: warning: ‘r.field[3]’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
     a->field[IF_CPU_FIELD] &= ~IF_CPU_LEVEL_MASK;

Indeed, iflag_set_all_features() doesn't set field[IF_CPU_FIELD]
If I modify the boundary in iflag_set_all_features() to include
IF_CPU_FIELD, then the warning is gone. (Although I am not sure
that such a change is correct here.)

diff --git a/include/iflag.h b/include/iflag.h
index 5280703e..98cd9620 100644
--- a/include/iflag.h
+++ b/include/iflag.h
@@ -137,7 +137,7 @@ static inline void iflag_set_all_features(iflag_t *a)
     size_t i;

-    for (i = IF_FEATURE_FIELD; i < IF_CPU_FIELD; i++)
+    for (i = IF_FEATURE_FIELD; i <= IF_CPU_FIELD; i++)
         a->field[i] = ~UINT32_C(0);

You are receiving this mail because:
You are on the CC list for the bug.
You are watching all bug changes.

More information about the Nasm-bugs mailing list