[llvm-bugs] [Bug 43231] New: -Wmissing-field-initializers warning missing for field designators

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 5 16:13:22 PDT 2019


            Bug ID: 43231
           Summary: -Wmissing-field-initializers warning missing for field
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: leonardchan 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

Given the following code

// ~/misc/test.cpp
struct foo {
  int x;
  int y;

void func() {
  struct foo f = { 11 };
  (void) f;

And compiling with `bin/clang++ ~/misc/test.cpp -c
-Wmissing-field-initializers`, we get the missing field initializers warning.

$ bin/clang++ ~/misc/test.cpp -c -Wmissing-field-initializers
/usr/local/google/home/leonardchan/misc/test.cpp:7:23: warning: missing field
'y' initializer [-Wmissing-field-initializers]
  struct foo f = { 11 };
1 warning generated.

But if we instead initialize `f` with `{ .x = 11 }`, we get no warning. In both
cases, y is still uninitialized but we only get the warning for the first case.
I think we should emit this diagnostic in both cases.

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/20190905/4cc81f00/attachment.html>

More information about the llvm-bugs mailing list