https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98641

--- Comment #8 from Alex Richardson <Alexander.Richardson at cl dot cam.ac.uk> 
---
(In reply to Jakub Jelinek from comment #3)
> I guess I have big questions on what exactly will it do during constexpr
> evaluation - if it is on a pointer to object with certain alignment, for
> smaller alignment arguments guess it is just like pointer arithmetics then,
> but if it asks for larger alignment, shall it make it non-constant
> expression?

When I implemented this for clang, I made the expression no longer constant if
__builtin_is_aligned() cannot be evaluated to true (since it might actually be
true at run time).
Therefore the following gives a "non a constant expression error rather than
returning false":

extern int x;
_Static_assert(__builtin_is_aligned(&x, 8), "");

See
https://github.com/llvm/llvm-project/commit/8c387cbea76b169f1f8ecc7693797e96567ed896#diff-b69ce3cbe3c48b9fac72f4c22fe7bb425c8757b144a87c44347ff1522360460fR211

Reply via email to