On Wed, Oct 27, 2021 at 10:16 AM Olivier Matz <olivier.m...@6wind.com> wrote: > > Do you have the explanation or can you point me at some standard > > explaining the difference in treatment? > > Let me try an explanation, hope it is the correct one. > > In the first case, this is an assignment as described in 6.5.16 of > the standard [1]: > > *fpo = (struct rte_eth_fp_ops) { .rx_pkt_burst = dummy_eth_rx_burst, ... }; > > The compiler expects the right side to be an expression. The expression > is a "compound literal", as described in 6.5.2.5: > > 1. The type name shall specify a complete object type or an array of > unknown size, but not avariable length array type. > 2. All the constraints for initializer lists in 6.7.9 also apply to > compound literals > > The second cast { ..., .rxq = (struct rte_ethdev_qdata) { ... } } is > inside a construction that behaves like an initialization (according to > the second point above). The compiler already knows the type of the > struct (and therefore the types of the fields), so the cast is not > required. > > [1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
I read/understand it like this too. Thanks a lot, reading standards is always illuminating. -- David Marchand