https://gcc.gnu.org/g:7c47badcdc8625ea53aed275be96c32bc78db25b

commit r16-3-g7c47badcdc8625ea53aed275be96c32bc78db25b
Author: Sam James <s...@gentoo.org>
Date:   Mon Mar 24 04:32:47 2025 +0000

    doc: say "compatible types" for -fstrict-aliasing
    
    Include the term used in the standard to ease further research for users,
    and while at it, rephrase the description of the rule entirely using
    Alexander Monakov's suggestion: it was previously wrong (and imprecise) as
    "the same address" may well be re-used later on, and the issue is the
    access via an expression of the wrong type.
    
    gcc/ChangeLog:
    
            * doc/invoke.texi: Use "compatible types" term. Rephrase to be
            more precise (and correct).

Diff:
---
 gcc/doc/invoke.texi | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 14a78fd236f6..020442aa032e 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -14649,12 +14649,14 @@ Enabled at levels @option{-O2}, @option{-O3}, 
@option{-Os}.
 @item -fstrict-aliasing
 Allow the compiler to assume the strictest aliasing rules applicable to
 the language being compiled.  For C (and C++), this activates
-optimizations based on the type of expressions.  In particular, an
-object of one type is assumed never to reside at the same address as an
-object of a different type, unless the types are almost the same.  For
-example, an @code{unsigned int} can alias an @code{int}, but not a
-@code{void*} or a @code{double}.  A character type may alias any other
-type.
+optimizations based on the type of expressions.  In particular, accessing
+an object of one type via an expression of a different type is not allowed,
+unless the types are @dfn{compatible types}, differ only in signedness or
+qualifiers, or the expression has a character type.  Accessing scalar
+objects via a corresponding vector type is also allowed.
+
+For example, an @code{unsigned int} can alias an @code{int}, but not a
+@code{void*} or a @code{double}.  A character type may alias any other type.
 
 @anchor{Type-punning}Pay special attention to code like this:
 @smallexample

Reply via email to