From: Nathan Chancellor <nathan@kernel.org>
To: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Cc: David Binderman <dcb314@hotmail.com>,
"jagathjog1996@gmail.com" <jagathjog1996@gmail.com>,
"jic23@kernel.org" <jic23@kernel.org>,
"lars@metafoo.de" <lars@metafoo.de>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: linux-6.12-rc1/drivers/iio/imu/bmi323/bmi323_core.c:133: Array contents defined but not used ?
Date: Mon, 30 Sep 2024 13:26:42 -0700 [thread overview]
Message-ID: <20240930202642.GA1497385@thelio-3990X> (raw)
In-Reply-To: <0342111e-47f7-4981-a1f1-e694392fa741@gmail.com>
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
next prev parent reply other threads:[~2024-09-30 20:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-30 13:49 David Binderman
2024-09-30 13:58 ` Javier Carrasco
2024-09-30 14:04 ` Javier Carrasco
2024-09-30 15:15 ` Nathan Chancellor
2024-09-30 16:50 ` Javier Carrasco
2024-09-30 20:26 ` Nathan Chancellor [this message]
2024-09-30 20:46 ` Javier Carrasco
2024-09-30 14:19 ` Lars-Peter Clausen
2024-09-30 14:47 ` Jonathan Cameron
2024-09-30 14:47 ` Denis Benato
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240930202642.GA1497385@thelio-3990X \
--to=nathan@kernel.org \
--cc=dcb314@hotmail.com \
--cc=jagathjog1996@gmail.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®