https://bugs.llvm.org/show_bug.cgi?id=45734

            Bug ID: 45734
           Summary: missing warning for uninitialized struct member
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: a...@linaro.org
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
                    neeil...@live.com, richard-l...@metafoo.co.uk

Test-building linux kernels, I found new bugs with gcc-10 that neither older
gcc versions nor clang report. See this example at https://godbolt.org/z/pYDWPx

struct s {
    int a; // always initialized
    int b; // partially initialized, gcc-10 warns
    int c; // not initialized, no warning
};

void f(void *p, int flag)
{
    struct s s;

    s.a = 0;
    if (flag)
        s.b |= 1;
    else
        s.b &= ~1;

    __builtin_memcpy(p, &s, sizeof(s));
}

Ideally there would be a warning for both s.b and s.c, but clang currently
warns for neither struct member.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to