<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Should = { 0 }; fire -Wmissing-braces in C99?"
   href="https://bugs.llvm.org/show_bug.cgi?id=32156">32156</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Should = { 0 }; fire -Wmissing-braces in C99?
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.9
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>gpakosz@pempek.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hello,

I noticed GCC and clang behave differently regarding -Wmissing-braces.

In C99, I'm wondering whether "= { 0 };" should warn when initializing a struct
defined with another struct as member and so on and so forth.

For example, <a href="https://godbolt.org/g/WLySA2">https://godbolt.org/g/WLySA2</a>
struct Bar
{
  int i;
};

struct Foo
{
  struct Bar bar;
};

int main(int argc, char* argv[])
{
  //struct Foo foo = { { 0 } };
  struct Foo foo = { 0 };

  return foo.bar.i;
}

Would struct Bar contain another struct Baz, then I would need to initialize
foo with 3 levels of nested braces. However, when initializing struct Foo, all
that matters is that it all gets initialized to 0. I don't believe I should
have to jump from header to header to figure out the number of nested braces I
need to use or that I should be brute-force adding levels of { } until the
compiler stops complaining.

Also, contrary to clang, it seems recent GCC versions stopped emitting
-Wmissing-braces when one writes = { 0 };

What do you think?</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>