Skip to content

Commit dcd27ec

Browse files
committed
!fixup add Strict Aliasing section to docs.
1 parent 059c126 commit dcd27ec

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

clang/docs/UsersManual.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2489,6 +2489,23 @@ are listed below.
24892489
24902490
$ clang -fuse-ld=lld -Oz -Wl,--icf=safe -fcodegen-data-use code.cc
24912491
2492+
Strict Aliasing
2493+
---------------
2494+
2495+
Clang by default applies C/C++'s strict aliasing rules during optimizations. In
2496+
cases C and C++ rules diverge, the more conservative rules are used. Clang does
2497+
not make use of strict aliasing rules in all cases yet, including unions and
2498+
variable-sized arrays. That may change in the future.
2499+
2500+
As of Clang 20, strict aliasing rules are also applied to nested pointers. The
2501+
new behavior can be disabled using ``-fno-pointer-tbaa``. Note that Clang does
2502+
not apply strict aliasing rules to `void*` pointers to avoid breaking existing
2503+
code, even though this is not required by the standard.
2504+
2505+
Strict aliasing violations in the source may change program behavior and
2506+
``-fno-strict-aliasing`` disables use of the strict aliasing rules. There also
2507+
is an experimental :doc:`TypeSanitizer` to detect strict aliasing voliations.
2508+
24922509
Profile Guided Optimization
24932510
---------------------------
24942511

0 commit comments

Comments
 (0)