Hi Javier, On Mon, Sep 30, 2024 at 06:50:14PM +0200, Javier Carrasco wrote: > But if that wasn't the case, and since you can't use sizeof(<type>), > should it be marked with __maybe_unused / __attribute__((unused)) even > though it's known in advance that it won't be used, or at least that its > use will be to get its size? Correct. > Is it then just to silence the warning, or does it have other > implications? Thanks again! Yes, the use of the unused attribute would just be to silence the warning; the variable would still not be emitted in the final binary. clang's behavior matches GCC's (aside from the special warning): https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-unused-variable-attribute If the variable needed to be emitted in the object file, __attribute__((used)) would need to be used, which explicitly has code generation implications: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-used-variable-attribute A contrived example: https://godbolt.org/z/oGGbqK98o Cheers, Nathan