@@ -2497,14 +2497,21 @@ cases C and C++ rules diverge, the more conservative rules are used. Clang does
2497
2497
not make use of strict aliasing rules in all cases yet, including unions and
2498
2498
variable-sized arrays. That may change in the future.
2499
2499
2500
+ Internally Clang encodes the strict aliasing rules in LLVM IR using type-based
2501
+ alias analysis (TBAA) metadata.
2502
+
2503
+ Note that clang-cl disables strict aliasing by default, see
2504
+ :ref: `Strict aliasing in clang-cl. <clang_cl_strict_aliasing >`
2505
+
2500
2506
As of Clang 20, strict aliasing rules are also applied to nested pointers. The
2501
2507
new behavior can be disabled using ``-fno-pointer-tbaa ``. Note that Clang does
2502
2508
not apply strict aliasing rules to `void* ` pointers to avoid breaking existing
2503
2509
code, even though this is not required by the standard.
2504
2510
2505
2511
Strict aliasing violations in the source may change program behavior and
2506
2512
``-fno-strict-aliasing `` disables use of the strict aliasing rules. There also
2507
- is an experimental :doc: `TypeSanitizer ` to detect strict aliasing voliations.
2513
+ is an experimental TypeSanitizer to detect strict aliasing voliations, which
2514
+ can be enabled by ``-fsanitize=type ``.
2508
2515
2509
2516
Profile Guided Optimization
2510
2517
---------------------------
@@ -5289,6 +5296,7 @@ The Visual C++ Toolset has a slightly more elaborate mechanism for detection.
5289
5296
Restrictions and Limitations compared to Clang
5290
5297
----------------------------------------------
5291
5298
5299
+ .. _clang_cl_strict_aliasing :
5292
5300
Strict Aliasing
5293
5301
^^^^^^^^^^^^^^^
5294
5302
0 commit comments