Closed
Description
- implemented in const fn integer operations #51299
- documentation
- stabilization PR in Stabilize const_int_ops integer methods #51364
One thing that I would like to do is to compile-time assert that the log2 of an alignment is less a given size. A simple way to do log2 of a power of 2 is to use trailing_zeros
. But trailing_zeros
is not const, so it's not possible to do a compile-time check.
The equivalent __builtin
s in clang are const (example: https://godbolt.org/g/RxWczn) so llvm should be able to handle that.
However, adding const
to the functions in core::num
requires adding const
to the corresponding intrinsics, and that is not supported (extern items cannot be 'const'
)