Skip to content

Commit ec48405

Browse files
committed
Fix mistake: static initialization code cannot access other static objects.
Specifically, the eid->type() call depends on the order of linking.
1 parent 0c2c94f commit ec48405

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

library/DataStaticsFields.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace df {
3636
pointer_identity identity_traits<void*>::identity;
3737
stl_ptr_vector_identity identity_traits<std::vector<void*> >::identity;
3838
stl_bit_vector_identity identity_traits<std::vector<bool> >::identity;
39+
bit_array_identity identity_traits<BitArray<int> >::identity;
3940

4041
buffer_container_identity buffer_container_identity::base_instance;
4142

library/include/DataIdentity.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,11 @@ namespace df
500500
static container_identity *get();
501501
};
502502

503+
template<> struct identity_traits<BitArray<int> > {
504+
static bit_array_identity identity;
505+
static bit_container_identity *get() { return &identity; }
506+
};
507+
503508
template<class T> struct identity_traits<BitArray<T> > {
504509
static bit_container_identity *get();
505510
};
@@ -553,9 +558,7 @@ namespace df
553558

554559
template<class T>
555560
inline bit_container_identity *identity_traits<BitArray<T> >::get() {
556-
static type_identity *eid = identity_traits<T>::get();
557-
static enum_identity *reid = eid->type() == DFHack::IDTYPE_ENUM ? (enum_identity*)eid : NULL;
558-
static bit_array_identity identity(reid);
561+
static bit_array_identity identity(identity_traits<T>::get());
559562
return &identity;
560563
}
561564

0 commit comments

Comments
 (0)