Re: [PATCH] [RFC] Initialization of unused function parameters

From: Peter Zijlstra
Date: Tue Jun 14 2022 - 18:27:40 EST


On Tue, Jun 14, 2022 at 11:08:33AM -0700, Nick Desaulniers wrote:

> One thing I'm curious about; if you have an aggregate in C (struct or
> array) and don't fully initialize the whole object, just
> members/sub-objects, but only use those I assume that's not UB? (Which
> is what my maybe_init example does). I think that's fine.

Perf does something like that. We only explicitly initialize the first
cacheline of a structure because that's *always* used. Any other field
will only be initialized on request.

At the time (and i've not benchmarked this in a good few years) that was
a significant performance win.