On Wed, Feb 23, 2022 at 05:33:57PM +0000, Qing Zhao wrote: > From my understanding, __builtin_clear_padding (&object), does not _use_ any > variable, > therefore, no uninitialized usage warning should be emitted for it.
__builtin_clear_padding (&object) sometimes expands to roughly: *(int *)((char *)&object + 32) = 0; etc., in that case it shouldn't be suppressed in any way, it doesn't read anything, only stores. Or at other times it is: *(int *)((char *)&object + 32) &= 0xfec7dab1; etc., in that case it reads bytes from the object which can be uninitialized, we mask some bits off and store. It is similar to what object.bitfld = 3; expands to, but usually only after the uninit pass. Though, we have the optimize_bit_field_compare optimization, that is done very early and I wonder what uninit does about that. Perhaps it ignores BIT_FIELD_REFs, I'd need to check that. Anyway, if we want to disable uninit warnings for __builtin_clear_padding, we should do that with suppress_warning on the read stmts that load a byte (or more adjacent ones) before they are masked off and stored again, so that we don't warn about that. Jakub