#include <iostream>
union gc_bits {
size_t value;
struct {
size_t arena : 2;
} bits;
constexpr gc_bits(size_t value_) : value(value_) {
}
};
static constexpr size_t get_max_arenas() {
return gc_bits(~0ULL).bits.arena;
}
size_t current_colour[get_max_arenas()]; // error
int main() {
std::cout << get_max_arenas() << std::endl;
}
The array declaration errors out because get_max_arenas is not a constexpr. I'm not clear on why this should be so.