]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
doc: say "compatible types" for -fstrict-aliasing
authorSam James <sam@gentoo.org>
Mon, 24 Mar 2025 04:32:47 +0000 (04:32 +0000)
committerSam James <sam@gentoo.org>
Thu, 17 Apr 2025 15:19:44 +0000 (16:19 +0100)
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).

gcc/doc/invoke.texi

index 14a78fd236f64185fc129f18b52b20692d49305c..020442aa032e79c13ad2ad66cd134e0d2d887bb9 100644 (file)
@@ -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