diff --git a/gtsam/discrete/DiscreteJunctionTree.cpp b/gtsam/discrete/DiscreteJunctionTree.cpp index 0c9eb10ef..e1fc2af11 100644 --- a/gtsam/discrete/DiscreteJunctionTree.cpp +++ b/gtsam/discrete/DiscreteJunctionTree.cpp @@ -51,7 +51,8 @@ struct PrintForestVisitorPre { void DiscreteJunctionTree::print(const std::string& s, const KeyFormatter& keyFormatter) const { PrintForestVisitorPre visitor(keyFormatter); - treeTraversal::DepthFirstForest(*this, std::string(s), visitor); + std::string parentString = s; + treeTraversal::DepthFirstForest(*this, parentString, visitor); } } // namespace gtsam