From: Uros Bizjak <ubizjak@gmail.com>
To: Sparse Mailing-list <linux-sparse@vger.kernel.org>
Cc: Dan Carpenter <dan.carpenter@linaro.org>, Chris Li <sparse@chrisli.org>
Subject: typeof() preserves address space information
Date: Thu, 16 Oct 2025 17:31:02 +0200 [thread overview]
Message-ID: <CAFULd4ZV6OiDZF8zknddrxPRTD5vhSQE6nEux4dr+2p1A7N6uA@mail.gmail.com> (raw)
The following testcase:
--cut here--
#ifdef __CHECKER__
# define __seg_gs __attribute__((address_space(__seg_gs)))
# define __seg_fs __attribute__((address_space(__seg_fs)))
#endif
#define __read(var) (*(volatile typeof(var) *)&(var))
extern int __seg_gs m;
int foo (void);
int foo (void)
{
return __read (m);
}
--cut here--
compiles with GCC (15+) without warnings, but sparse warns:
_.c:13:10: warning: cast removes address space '__seg_gs' of expression
typeof () operator should preserve all qualifiers (const, volatile,
__seg_gs, etc). OTOH, typeof_unqual () operator strips all qualifiers
and returns unqualified type of what typeof () returns. Please see
notes of [1].
[1] https://en.cppreference.com/w/c/language/typeof.html
Uros.
next reply other threads:[~2025-10-16 15:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 15:31 Uros Bizjak [this message]
2025-10-21 7:04 ` typeof() preserves address space information Chris Li
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=CAFULd4ZV6OiDZF8zknddrxPRTD5vhSQE6nEux4dr+2p1A7N6uA@mail.gmail.com \
--to=ubizjak@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).