Hi,

the attached patch amends the documentation of -ftrivial-auto-var-init=zero to add another (IMHO more widespread) example.

Thank you,

--
Giuseppe D'Angelo
From 3fb040b093e4c65fc942530198c89727120f09da Mon Sep 17 00:00:00 2001
From: Giuseppe D'Angelo <[email protected]>
Date: Fri, 14 Aug 2026 14:04:22 +0200
Subject: [PATCH 1/2] doc: provide another example for
 -ftrivial-auto-var-init=zero

On the Itanium ABI an uninitialized pointer to data member is
*not* initialized to the corresponding null pointer value when
its storage is zero-filled by -ftrivial-auto-var-init=zero;
this is because pointers to data members represent offsets,
and -1 is used to represent null:

https://itanium-cxx-abi.github.io/cxx-abi/abi.html#data-member-pointers

As (IMHO) this is a relatively more common instance than e.g.
hardbool, add this example to the option's documentation.

gcc/ChangeLog:

	* doc/invoke.texi: Add another example to the docs of
	'-ftrivial-auto-var-init'.

Signed-off-by: Giuseppe D'Angelo <[email protected]>
---
 gcc/doc/invoke.texi | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index f2bcf410bf0..c2342a14057 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -15485,6 +15485,12 @@ exception is that (non-hardened) boolean variables that fit in registers
 are initialized with @code{false} (zero), even when @samp{pattern} is
 requested.
 
+As another example, on targets that use the Itanium C++ ABI, a variable
+of pointer to data member type is not initialized to the null member
+pointer value by @samp{zero} initialization: in that ABI such a variable
+holds an offset, whose null value is represented as @code{-1} rather
+than @code{0}.
+
 You can control this behavior for a specific variable by using the variable
 attribute @code{uninitialized} standard attribute (@pxref{Common Attributes})
 or the C++26 @code{[[indeterminate]]}.
-- 
2.43.0

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to