[clang] [clang][Sema] Diagnose passing function pointer to `__builtin_assume_aligned` (PR #153552)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 15 05:24:06 PDT 2025


AaronBallman wrote:

> I've switched to `checkBuiltinArgument`, but it causes an issue that I'd like input on before I continue. `clang/test/CodeGen/catch-alignment-assumption-ignorelist.c` tests that UBSan doesn't validate the alignment of pointers to volatile. [Several UBSan checks have this exception](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#volatile), but I don't understand the motivation behind it. With this change, the `volatile`-ness of the pointer is lost when passed into `__builtin_assume_aligned`, so the UBSan checks are generated. To _me_ this seems like an improvement; after all, checking alignment does not dereference the pointer, so why does it matter if it points to volatile?

CC @zygoloid @vitalybuka for opinions

https://github.com/llvm/llvm-project/pull/153552


More information about the cfe-commits mailing list