Sebastian Pipping <[email protected]> writes: > Hello Sam, > > > On 11/24/26 00:35, Sam James wrote: >> Why Clang >= 20? Clang has supported this flag since forever. > > at > https://releases.llvm.org/20.1.0/tools/clang/docs/ReleaseNotes.html > it reads: > > Clang now emits distinct type-based alias analysis tags for > incompatible pointers by default, enabling more powerful alias > analysis when accessing pointer types. This change may silently change > code behavior for code containing strict-aliasing violations.
The next part of that same paragraph says:
The new default behavior can be disabled using -fno-pointer-tbaa.
Clang has performed optimisations of this type for a long time, it just
does so more aggressively now.
If you want to gate the behaviour on >= 20, you should use
-fno-pointer-tbaa.
But if you're not confident the codebase is TBAA-safe, you should just
use -fno-strict-aliasing unconditionally where the compiler supports it.
>
>
>> Note that -Wstrict-aliasing=1 is the most aggressive level [0].
>
> It also says "least accurate".
Yes, but the way you mentioned it made me think "it's [even]
-Wstrict-alisaing=3" clean, as if it's the toughest level. Of course you
get false positives if you crank up the sensitivity.
>
>
>> Anyway,
>> in terms of detection, Clang has TypeSanitizer (-fsanitize=type) but it
>> has some issues still. Someone has proposed it for GCC now too.
>> [0]
>> https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-aliasing
>
> I'm in the process of adding Clang's TypeSanitizer to CI.
>
Excellent.
> Best
>
>
>
> Sebastian
sam
signature.asc
Description: PGP signature
