[Bug c++/85461] A simple recursive TMP static const initializer defeats gcc
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Dec 22 01:45:40 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85461
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Using constexpr is a decent workaround.
Note enum version of this is rejected by all compilers:
template<unsigned int v>
struct bitWidthHolding {
enum {width = (v == 0) ? 0 : bitWidthHolding<(v>>1)>::width + 1};
};
int a = bitWidthHolding<255>::width;
Which I find interesting.
More information about the Gcc-bugs
mailing list