Skip to content

Commit 0446809

Browse files
committed
!fixup add Strict Aliasing section to docs.
1 parent b98ab99 commit 0446809

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
@@ -2486,6 +2486,23 @@ are listed below.
24862486
24872487
$ clang -fuse-ld=lld -Oz -Wl,--icf=safe -fcodegen-data-use code.cc
24882488
2489+
Strict Aliasing
2490+
---------------
2491+
2492+
Clang by default applies C/C++'s strict aliasing rules during optimizations. In
2493+
cases C and C++ rules diverge, the more conservative rules are used. Clang does
2494+
not make use of strict aliasing rules in all cases yet, including unions and
2495+
variable-sized arrays. That may change in the future.
2496+
2497+
As of Clang 20, strict aliasing rules are also applied to nested pointers. The
2498+
new behavior can be disabled using ``-fno-pointer-tbaa``. Note that Clang does
2499+
not apply strict aliasing rules to `void*` pointers to avoid breaking existing
2500+
code, even though this is not required by the standard.
2501+
2502+
Strict aliasing violations in the source may change program behavior and
2503+
``-fno-strict-aliasing`` disables use of the strict aliasing rules. There also
2504+
is an experimental :doc:`TypeSanitizer` to detect strict aliasing voliations.
2505+
24892506
Profile Guided Optimization
24902507
---------------------------
24912508

0 commit comments

Comments
 (0)