From: Alexandre Oliva <oliva@adacore.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Introduce hardbool attribute for C
Date: Fri, 08 Jul 2022 12:28:37 -0300 [thread overview]
Message-ID: <or7d4nk4ii.fsf@lxoliva.fsfla.org> (raw)
In-Reply-To: <CAFiYyc3NFmmipnVOYxL0=8RWvtkX3ziPnjBzYbuu07bnoy93Bg@mail.gmail.com> (Richard Biener's message of "Fri, 8 Jul 2022 08:58:34 +0200")
On Jul 8, 2022, Richard Biener <richard.guenther@gmail.com> wrote:
> The documentation should probably be explicit about this case.
Please consider, for purposes of review, the following incremental
patchlet as if integrated with yesterday's submission.
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index a63a94158341a..a1dcd581dd8ad 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -8483,7 +8483,22 @@ followed by a mapping from @code{false} and @code{true} to
typedef char __attribute__ ((__hardbool__ (0x5a))) hbool;
hbool first = 0; /* False, stored as (char)0x5a. */
hbool second = !first; /* True, stored as ~(char)0x5a. */
-@end smallexample
+
+static hbool zeroinit; /* False, stored as (char)0x5a. */
+auto hbool uninit; /* Undefined, may trap. */
+@end smallexample
+
+When zero-initializing a variable or field of hardened boolean type
+(presumably held in static storage) the implied zero initializer gets
+converted to @code{_Bool}, and then to the hardened boolean type, so
+that the initial value is the hardened representation for @code{false}.
+Using that value is well defined. This is @emph{not} the case when
+variables and fields of such types are uninitialized (presumably held in
+automatic or dynamic storage): their values are indeterminate, and using
+them invokes undefined behavior. Using them may trap or not, depending
+on the bits held in the storage (re)used for the variable, if any, and
+on optimizations the compiler may perform on the grounds that using
+uninitialized values invokes undefined behavior.
@item may_alias
--
Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/
Free Software Activist GNU Toolchain Engineer
Disinformation flourishes because many people care deeply about injustice
but very few check the facts. Ask me about <https://stallmansupport.org>
next prev parent reply other threads:[~2022-07-08 15:28 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-07 19:59 Alexandre Oliva
2022-07-08 6:58 ` Richard Biener
2022-07-08 13:39 ` Sebastian Huber
2022-07-08 15:28 ` Alexandre Oliva [this message]
2022-07-08 15:28 ` Alexandre Oliva
2022-07-11 9:59 ` Richard Biener
2022-08-09 13:53 ` Alexandre Oliva
2023-06-16 5:35 ` Alexandre Oliva
2023-06-19 18:48 ` Bernhard Reutner-Fischer
2023-06-22 1:08 ` Alexandre Oliva
2023-06-22 21:15 ` Bernhard Reutner-Fischer
2023-06-24 2:57 ` Alexandre Oliva
2023-06-21 15:57 ` Qing Zhao
2023-06-22 2:35 ` Alexandre Oliva
2023-06-23 21:40 ` Qing Zhao
2023-06-24 2:38 ` Alexandre Oliva
2023-06-26 19:05 ` Qing Zhao
2023-06-28 7:26 ` Alexandre Oliva
2023-06-28 15:07 ` Qing Zhao
2023-06-29 10:30 ` Alexandre Oliva
2023-06-29 15:21 ` Qing Zhao
2023-06-24 4:42 ` Alexandre Oliva
2023-10-20 5:31 ` [PATCH v4] " Alexandre Oliva
2023-11-20 12:45 ` Alexandre Oliva
2023-11-20 13:56 ` Richard Biener
2023-11-29 9:30 ` Alexandre Oliva
[not found] ` <20230403012803.29ccf00b@nbbrfq>
[not found] ` <orzg7l8rr4.fsf@lxoliva.fsfla.org>
[not found] ` <6890D6BA-73DC-4F91-9413-228492A7F09B@gmail.com>
[not found] ` <ora5x0x8x9.fsf@lxoliva.fsfla.org>
2023-06-16 6:52 ` [PATCH] " Thomas Koenig
2023-06-16 8:03 ` Alexandre Oliva
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=or7d4nk4ii.fsf@lxoliva.fsfla.org \
--to=oliva@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
/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).