Skip to content

Unexpected -Wuninitialized with asm goto with outputs #1521

@nathanchance

Description

@nathanchance

The kernel test robot reported an issue with a PowerPC patch taking advantage of asm goto with outputs. This appears to be a false positive, as the variable is only used on the fallthrough path. A simplified reproducer:

$ cat test.c
static inline int copy_inst_from_kernel_nofault(unsigned int *inst,
                                                unsigned int *src)
{
        unsigned int val;

        asm goto("1: lwz %U1%X1 %0, %1   # get_user\n"
                 ".section __ex_table,\"a\";"
                 ".balign 4;"
                 ".long (1b) - . ;"
                 ".long (%l2) - . ;"
                 ".previous"
                 : "=r" (*(unsigned int *)(&val))
                 : "m<>" (*(unsigned int *)(src))
                 :
                 : Efault);

        *inst = val;
        return 0;

Efault:
        return -14; /* -EFAULT */
}

$ clang --target=powerpc-linux-gnu -Wuninitialized -fsyntax-only test.c
test.c:17:10: warning: variable 'val' is uninitialized when used here [-Wuninitialized]
        *inst = val;
                ^~~
test.c:4:18: note: initialize the variable 'val' to silence this warning
        unsigned int val;
                        ^
                         = 0
1 warning generated.

Metadata

Metadata

Assignees

Labels

-Wuninitialized[BUG] llvmA bug that should be fixed in upstream LLVM[FIXED][LLVM] 13This bug was fixed in LLVM 13.x[FIXED][LLVM] 14This bug was fixed in LLVM 14.xasm gotorelated to the implementation of asm goto

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions