<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/65576>65576</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            False positive on -Wmissing-braces for structure with array subobject
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          fsky3
      </td>
    </tr>
</table>

<pre>
    When the first object of a structure is an array of integers, the initialization of such structure with {0} will trigger -Wmissing-braces warning:

`struct my_struct {
    int a[1];
 int b;
};

struct my_struct stats = {0};

int get_b(void) {
    return stats.b;
}`

But when the array is a second member, the warning will not be triggerred.

Similar issues:
https://bugs.llvm.org/show_bug.cgi?id=21689 (missing-field-initializers too aggressive for C's {0})
https://bugs.llvm.org/show_bug.cgi?id=39931 (False positive on -Wmissing-braces for structure with non-integer subobject)

Tested on:

x86-64 clang 16.0.0 on Compiler Explorer ( https://godbolt.org/ )
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyclM9ygzYQxp9GXHbMgMTfA4c6Li_QzuSYEbAW2wrJI4k47tN3ZGwncW65CMSy-61--4H0npRB7Fi5Z-UhkWuYreuO_t-LSAY7XbrXGQ2EGeFIzgewwz84BrBHkOCDW8ewOgTyIA1I5-QlhsgEVOg84y_XVDIUSGr6TwayJr7h13H-kn-mMAOr9xmrD3AmrSE4Ugod7F4X8p6M2g1OjujhLJ0ho5j4g2UHlt3XKtuqwXJ5u92xer8FASC2BJKV-5yVBybugfh0eGxZ_Rna1h81fZDBAxOHe7dPCbGgwvA2MN68W5oYb7_34TCszmx10u_SVfa10n4NcL6z38hGyuBxtGaCBZcB3R3wDcqGztgAA94JOpzSr3X_ooW0dEDer-gfGOcQTtcd7xnvh1X5VOv3JbVOMd772Z7fhlWloyImepqYOPC8alpgvLkP6Eiop91j1ug8BGtBKuXQe3pHOFoHL4zX_kGPt7-VF20r8ijfS-0RTtZTiBrW_PRM1H0ym7Fmd7Mp-HXYbP1oZ1v_Rh9wAmuezPbRVLuqgFFLoyCv0izNouyLXU6k0cGfHydtHbrYHXw_mbLTYHW4nQsYb5OpE1MrWplgl1dtkdU8b5pk7upyEkXZTqMYkXMhcGxrbPlR5PlUllmVUMczLrI2q7NaVLxJi0oMjWibYqyHIm84KzJcJOkHyuQ69K4qy7pKtBxQ--uHz7nB8-YIxnn8D7gu5uziIFiRafLhcyBJoKCx-x33zckP4snqdPeEiMK8DuloF8b7qHm77E7ObkPqb97l_fUk_wcAAP__rXGDAg">