https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91195

--- Comment #6 from Jiangning Liu <jiangning.liu at amperecomputing dot com> ---
It seems -Werror=maybe-uninitialized cannot always work, and it fails to report
the error message for the case below. However, the option name is "maybe-xxx",
so I can understand it is OK, but for the same reason, it should be also OK if
we report error message for the original case.

$ cat pr89430-1.c
unsigned test(unsigned k, unsigned b) {
        unsigned a[2];
        if (b < a[k]) {
                a[k] = b;
        }
        return a[0]+a[1];
}
$ gcc -O2 -S pr89430-1.c -Werror=maybe-uninitialized
$ cat pr89430-1.s
        .file   "pr89430-1.c"
        .text
        .p2align 4
        .globl  test
        .type   test, @function
test:
.LFB0:
        .cfi_startproc
        movl    %edi, %edi
        cmpl    %esi, -8(%rsp,%rdi,4)
        cmovbe  -8(%rsp,%rdi,4), %esi
        movl    %esi, -8(%rsp,%rdi,4)
        movl    -4(%rsp), %eax
        addl    -8(%rsp), %eax
        ret
        .cfi_endproc
.LFE0:
        .size   test, .-test
        .ident  "GCC: (GNU) 10.0.0 20190722 (experimental)"
        .section        .note.GNU-stack,"",@progbits

Reply via email to