From: "Rebecca Cran" <rebecca@bsdio.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>
Subject: Enum size checks in Base.h (UINT32 not ISO C compatible)
Date: Wed, 8 Feb 2023 19:20:02 -0700 [thread overview]
Message-ID: <36f37eb3-05de-64c3-833e-f625376b6f70@bsdio.com> (raw)
In commit 6440385b17def888544c2454ffba58384b929a22
(https://github.com/tianocore/edk2/commit/6440385b17def888544c2454ffba58384b929a22)
enum size checks were added.
However, according to gcc, ISO C restricts the size of enum values to
int; building with -std=c11 -pedantic results in the error:
MdePkg/Include/Base.h:812:28: error: ISO C restricts enumerator values
to range of ‘int’ [-Werror=pedantic]
812 | __VerifyInt32EnumValue = 0xffffffff
Replacing 0xffffffff with 0x7fffffff fixes the problem.
It looks like this might change in C23, but since the use of
_Static_assert in Base.h we require at least C11 (and I suspect most
compilers aren't C23 compliant) which states:
"The expression that defines the value of an enumeration constant shall
be an integer constant expression that has a value representable as an int.
[Section 6.7.2.2]"
The UEFI Specification appears to say we require an INT32 (i.e. a signed
int) so is the existing code wrong?
--
Rebecca Cran
next reply other threads:[~2023-02-09 2:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 2:20 Rebecca Cran [this message]
2023-02-09 2:28 ` Enum size checks in Base.h (UINT32 not ISO C compatible) Michael D Kinney
2023-02-09 2:52 ` Rebecca Cran
2023-02-09 15:57 ` Rebecca Cran
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-list 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=36f37eb3-05de-64c3-833e-f625376b6f70@bsdio.com \
--to=devel@edk2.groups.io \
/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