Commit 9166952 "CarpetLib: Store registered gh, dh, th, gf, data etc. via sets, not via lists" replaced list<ggf> dh::gfs by set<ggf> dh::gfs. Unfortunately some code assumes that these containers are iterated over from varindex=0 to the last varindex. The set however is sorted by the address of the ggf structures it holds (the list was sorted by creation order which apparently happened to coincide with the variable index).
The bug manifests when storage is allocated for vectors of grid functions (eg vel) and recompose_allocate is called on vel before vel. Since only vel actually allocactes memory vel tries to refer to this memory and assert()s when trying to access not yet existing timelevels.
The attached patches (each!) fix the issues, once by using a vector<ggf*> indexed by the varindex which allows for simple iterators but comes at the price of having to deal with NULL pointers for not-yet registered ggfs.
The second uses a map<int,ggf*> which avoids this problem but comes at the price of having to deal with pairs for iterators.
Making the set<ggf> sorted by variable index is possible but awkward since C++ requires the sorting callback (type) to be part of the set type, ie one needs something like set<ggf,bool()(ggfconst,ggf*const)> as the type of the container.