[llvm-bugs] [Bug 52469] New: Missing warning due to uninitialized value because of construction order

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Nov 10 05:32:47 PST 2021


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

            Bug ID: 52469
           Summary: Missing warning due to uninitialized value because of
                    construction order
           Product: clang
           Version: 13.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: veluca at google.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The following piece of code does not generate a warning in clang 3.6+. It does
generate a warning in 3.5.2 (at least according to https://godbolt.org/), as
well as on GCC.

struct S {
    S(int& c): a(c) {}
    int* b = &a;
    int& a;
};

int f() {
    int x = 5;
    S s(x);
    return *s.b;
}

Moreover (and this may be an unrelated bug, or intentional), as of clang 13,
this code produces an empty function, while on clang 12 and earlier it produced
a single `ud2` instruction.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211110/706483be/attachment.html>


More information about the llvm-bugs mailing list