@@ -2497,14 +2497,21 @@ cases C and C++ rules diverge, the more conservative rules are used. Clang does
24972497not make use of strict aliasing rules in all cases yet, including unions and
24982498variable-sized arrays. That may change in the future.
24992499
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+
25002506As of Clang 20, strict aliasing rules are also applied to nested pointers. The
25012507new behavior can be disabled using ``-fno-pointer-tbaa ``. Note that Clang does
25022508not apply strict aliasing rules to `void* ` pointers to avoid breaking existing
25032509code, even though this is not required by the standard.
25042510
25052511Strict aliasing violations in the source may change program behavior and
25062512``-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 ``.
25082515
25092516Profile Guided Optimization
25102517---------------------------
@@ -5289,6 +5296,7 @@ The Visual C++ Toolset has a slightly more elaborate mechanism for detection.
52895296Restrictions and Limitations compared to Clang
52905297----------------------------------------------
52915298
5299+ .. _clang_cl_strict_aliasing :
52925300Strict Aliasing
52935301^^^^^^^^^^^^^^^
52945302
0 commit comments