Clang Static Analyzer and Strict Aliasing

Hi Cfe-dev,

I’m not particularly familiar with the clang static analzyer, so would like some help with a bug that was filed against it (when compiling for RISC-V, but I don’t think that’s the issue here, as the bug also shows up with the default target).

The bug is here: https://bugs.llvm.org/show_bug.cgi?id=47727

Is it expected that the static analzyer will catch (some?) strict aliasing issues like this?

Sam

Hi,

No, it shouldn’t reason or warn about strict aliasing. It potentially could and i’d love it to, but as of now it doesn’t. When it does, like in , it’s a bug in the static analyzer, namely yet another instance of . In particular, if you change one of the types to char (or something like that), it’ll bypass the strict aliasing rule and the analyzer would still emit a warning which would then be a definite false positive. I’ll reply to that bug report.

Thanks for the clarification! I’ll try to remember that when we get more Static Analyzer issues reported about RISC-V.

Sam