Skip to content

Commit 6d1ff04

Browse files
authored
Merge pull request #1589 from Idclip/treetype_gcc_fix
Fixed a crash with GCC11 in Tree::treeType()
2 parents 34095fa + 0a95028 commit 6d1ff04

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

openvdb/openvdb/tree/Tree.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,13 +1038,8 @@ class Tree: public TreeBase
10381038
RootNodeType mRoot; // root node of the tree
10391039
mutable AccessorRegistry mAccessorRegistry;
10401040
mutable ConstAccessorRegistry mConstAccessorRegistry;
1041-
1042-
static std::unique_ptr<const Name> sTreeTypeName;
10431041
}; // end of Tree class
10441042

1045-
template<typename _RootNodeType>
1046-
std::unique_ptr<const Name> Tree<_RootNodeType>::sTreeTypeName;
1047-
10481043

10491044
/// @brief Tree3<T, N1, N2>::Type is the type of a three-level tree
10501045
/// (Root, Internal, Leaf) with value type T and
@@ -1829,19 +1824,19 @@ template<typename RootNodeType>
18291824
inline const Name&
18301825
Tree<RootNodeType>::treeType()
18311826
{
1832-
static std::once_flag once;
1833-
std::call_once(once, []()
1827+
static std::string sTreeTypeName = []()
18341828
{
1829+
// @todo use RootNode::NodeChain::foreach() instead
18351830
std::vector<Index> dims;
18361831
Tree::getNodeLog2Dims(dims);
18371832
std::ostringstream ostr;
18381833
ostr << "Tree_" << typeNameAsString<BuildType>();
18391834
for (size_t i = 1, N = dims.size(); i < N; ++i) { // start from 1 to skip the RootNode
18401835
ostr << "_" << dims[i];
18411836
}
1842-
sTreeTypeName.reset(new Name(ostr.str()));
1843-
});
1844-
return *sTreeTypeName;
1837+
return ostr.str();
1838+
}();
1839+
return sTreeTypeName;
18451840
}
18461841

18471842

pendingchanges/init_fix.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
OpenVDB:
2+
- Bug Fixes:
3+
Fixed a bug when compiling with -fvisibility=hidden and GCC 11 which
4+
would cause a crash in openvdb::initialize()

0 commit comments

Comments
 (0)