On 2024-08-21 06:36, Bruno Haible wrote:
In summary, this paragraph makes no sense for structs.
Hmm, well, the paragraph makes sense to me. I suppose somebody could fire off a question to the C committee about the intent of the paragraph.
In the meantime it's an engineering decision - should we port to verrry picky implementations that complain about components of the struct not being initialized? This is a valid question regardless of the standard's intent.
I expect that it's not high priority to change the code, if the only picky implementation is SAST (which I've never used and which I suspect is chock-full of false positives anyway). If it's GCC's -fanalyzer or sanitizer or valgrind or something else we (or at least I) commonly use, though, that'd be a different matter.
Also, if the C committee comes back and says behavior is undefined, we might want to make the change, if only as insurance.
that 'return (struct ...) { initializers }' produces particularly good code with modern compilers)
Yeah, that's partly why I weighed in on this seemingly-obscure topic. I like the more-functional style and wouldn't want "undefined behavior" to get in its way.