[clang] [Clang] Fix crash in alignment builtins with null pointers (PR #224549)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 30 05:26:49 PDT 2026
AaronBallman wrote:
> Hi @AaronBallman @tbaederr, before I proceed with the follow-up changes, I'd like to make sure we're aligned on the intended behavior here.
>
> Eli suggested that, for pointers without a base whose exact numeric value is known, we could simply perform the arithmetic for align_up and align_down (with null pointers remaining null), even though integer-to-pointer casts are already in extension territory.
>
> Do you both agree with this direction? If so, I'll update the implementation accordingly and make sure the behavior is consistent between the old constant evaluator and the new constant interpreter.
The null pointer behavior makes sense to me. The behavior on integers cast to pointers is less clear to me, but I think it's reasonable enough to do math. But I wouldn't object strongly to making that ill-formed in a constant expression either; we could always relax the restriction later when a user has an actual use case for it. @tbaederr or others, do you have opinions on that case?
https://github.com/llvm/llvm-project/pull/224549
More information about the cfe-commits
mailing list