Your code relies on initialization order of two declarations:
template<class T> const int IdStore<T>::bitIdx{getNextId()};
template<class... A> const Bts BtsStore<A...>::bts{getBuildBts<A...>()};
// getBuildBts uses IdStore<T>::bitIdx as indexes to assign
If all of IdStore<T>::bitIdx
initializations happen before BtsStore<A...>::bts
then you get your expected behavior. If all of the happen after BtsStore<A...>::bts
then you get g++ behavior. Both orderings are allowed by standard:
3.6.2 Initialization of non-local variables
2 (...) Dynamic initialization of a non-local variable with static storage duration is either ordered or unordered. Definitions of explicitly specialized class template static data members have ordered initialization. Other class template static data members (i.e., implicitly or explicitly instantiated specializations) have unordered initialization.