Skip to content

Build failure with g++-12: 'unique_ptr' was not declared in this scope

Trying to build dynare 5.1 from source (with various patches for Octave 7 compatibility), with G++ 12.1.0-RC1 (which will be released in a week) gives the following errors:

2022-05-01T00:28:25.3736860Z In file included from ExprNode.cc:28:
2022-05-01T00:28:25.3737050Z DataTree.hh:120:10: error: 'unique_ptr' was not declared in this scope
2022-05-01T00:28:25.3737150Z   120 |   vector<unique_ptr<ExprNode>> node_list;
2022-05-01T00:28:25.3737220Z       |          ^~~~~~~~~~
2022-05-01T00:28:25.3737510Z DataTree.hh:38:1: note: 'std::unique_ptr' is defined in header '<memory>'; did you forget to '#include <memory>'?
2022-05-01T00:28:25.3737590Z    37 | #include "SubModel.hh"
2022-05-01T00:28:25.3737660Z   +++ |+#include <memory>
2022-05-01T00:28:25.3737720Z    38 | 
2022-05-01T00:28:25.3737830Z DataTree.hh:120:21: error: template argument 1 is invalid
2022-05-01T00:28:25.3737960Z   120 |   vector<unique_ptr<ExprNode>> node_list;
2022-05-01T00:28:25.3738030Z       |                     ^~~~~~~~
2022-05-01T00:28:25.3738140Z DataTree.hh:120:21: error: template argument 2 is invalid
2022-05-01T00:28:25.3738340Z DataTree.hh:120:29: error: expected unqualified-id before '>' token
2022-05-01T00:28:25.3738430Z   120 |   vector<unique_ptr<ExprNode>> node_list;
2022-05-01T00:28:25.3738500Z       |                             ^~
2022-05-01T00:28:25.3740470Z DataTree.hh: In member function 'ExprNode* DataTree::AddUnaryOp(UnaryOpcode, expr_t, int, int, int, const std::string&, const std::vector<int>&)':
2022-05-01T00:28:25.3740680Z DataTree.hh:398:13: error: 'make_unique' was not declared in this scope
2022-05-01T00:28:25.3740940Z   398 |   auto sp = make_unique<UnaryOpNode>(*this, node_list.size(), op_code, arg, arg_exp_info_set, param1_symb_id, param2_symb_id, adl_param_name, adl_lags);
2022-05-01T00:28:25.3741010Z       |             ^~~~~~~~~~~
2022-05-01T00:28:25.3741300Z DataTree.hh:398:13: note: 'std::make_unique' is defined in header '<memory>'; did you forget to '#include <memory>'?
2022-05-01T00:28:25.3741500Z DataTree.hh:398:36: error: expected primary-expression before '>' token
2022-05-01T00:28:25.3741720Z   398 |   auto sp = make_unique<UnaryOpNode>(*this, node_list.size(), op_code, arg, arg_exp_info_set, param1_symb_id, param2_symb_id, adl_param_name, adl_lags);
2022-05-01T00:28:25.3741790Z       |                                    ^
2022-05-01T00:28:25.3741980Z DataTree.hh:398:45: error: 'node_list' was not declared in this scope
2022-05-01T00:28:25.3742180Z   398 |   auto sp = make_unique<UnaryOpNode>(*this, node_list.size(), op_code, arg, arg_exp_info_set, param1_symb_id, param2_symb_id, adl_param_name, adl_lags);
2022-05-01T00:28:25.3742320Z       |                                             ^~~~~~~~~
2022-05-01T00:28:25.3742610Z DataTree.hh: In member function 'ExprNode* DataTree::AddBinaryOp(expr_t, BinaryOpcode, expr_t, int)':
2022-05-01T00:28:25.3742810Z DataTree.hh:424:13: error: 'make_unique' was not declared in this scope
2022-05-01T00:28:25.3742970Z   424 |   auto sp = make_unique<BinaryOpNode>(*this, node_list.size(), arg1, op_code, arg2, powerDerivOrder);
2022-05-01T00:28:25.3743040Z       |             ^~~~~~~~~~~
2022-05-01T00:28:25.3743330Z DataTree.hh:424:13: note: 'std::make_unique' is defined in header '<memory>'; did you forget to '#include <memory>'?
2022-05-01T00:28:25.3743520Z DataTree.hh:424:37: error: expected primary-expression before '>' token
2022-05-01T00:28:25.3743680Z   424 |   auto sp = make_unique<BinaryOpNode>(*this, node_list.size(), arg1, op_code, arg2, powerDerivOrder);
2022-05-01T00:28:25.3743760Z       |                                     ^
2022-05-01T00:28:25.3743950Z DataTree.hh:424:46: error: 'node_list' was not declared in this scope
2022-05-01T00:28:25.3744110Z   424 |   auto sp = make_unique<BinaryOpNode>(*this, node_list.size(), arg1, op_code, arg2, powerDerivOrder);
2022-05-01T00:28:25.3744190Z       |                                              ^~~~~~~~~
2022-05-01T00:28:25.3744490Z DataTree.hh: In member function 'ExprNode* DataTree::AddTrinaryOp(expr_t, TrinaryOpcode, expr_t, expr_t)':
2022-05-01T00:28:25.3744680Z DataTree.hh:451:13: error: 'make_unique' was not declared in this scope
2022-05-01T00:28:25.3744830Z   451 |   auto sp = make_unique<TrinaryOpNode>(*this, node_list.size(), arg1, op_code, arg2, arg3);
2022-05-01T00:28:25.3744890Z       |             ^~~~~~~~~~~
2022-05-01T00:28:25.3745170Z DataTree.hh:451:13: note: 'std::make_unique' is defined in header '<memory>'; did you forget to '#include <memory>'?
2022-05-01T00:28:25.3748160Z DataTree.hh:451:38: error: expected primary-expression before '>' token
2022-05-01T00:28:25.3748320Z   451 |   auto sp = make_unique<TrinaryOpNode>(*this, node_list.size(), arg1, op_code, arg2, arg3);
2022-05-01T00:28:25.3748400Z       |                                      ^
2022-05-01T00:28:25.3748640Z DataTree.hh:451:47: error: 'node_list' was not declared in this scope
2022-05-01T00:28:25.3748820Z   451 |   auto sp = make_unique<TrinaryOpNode>(*this, node_list.size(), arg1, op_code, arg2, arg3);
2022-05-01T00:28:25.3748910Z       |                                               ^~~~~~~~~