aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2025-03-24 04:32:47 +0000
committerSam James <sam@gentoo.org>2025-04-17 16:19:44 +0100
commit7c47badcdc8625ea53aed275be96c32bc78db25b (patch)
tree40adea7a2ee89d42ed626c8b204b77694bd3c305
parentc237297ee596545552f48ec9582d7d16703d8949 (diff)
downloadgcc-7c47badcdc8625ea53aed275be96c32bc78db25b.zip
gcc-7c47badcdc8625ea53aed275be96c32bc78db25b.tar.gz
gcc-7c47badcdc8625ea53aed275be96c32bc78db25b.tar.bz2
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).
-rw-r--r--gcc/doc/invoke.texi14
1 files changed, 8 insertions, 6 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 14a78fd..020442a 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