New warnings currently emitted by the shortly-to-be-released GCC 13.
This is building master (eebc24bfc6d2d809952e27c7fe269452f319455f), using GCC gcc (GCC) 13.0.0 20230115 (Red Hat 13.0.0-0):
external_signer.cpp: In static member function ‘static bool ExternalSigner::Enumerate(const std::string&, std::vector<ExternalSigner>&, std::string)’:
external_signer.cpp:33:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
33 | const UniValue& error = find_value(signer, "error");
| ^~~~~
external_signer.cpp:33:43: note: the temporary was destroyed at the end of the full expression ‘find_value((* & signer), std::__cxx11::basic_string<char>(((const char*)"error"), std::allocator<char>()))’
33 | const UniValue& error = find_value(signer, "error");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~
external_signer.cpp:41:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
41 | const UniValue& fingerprint = find_value(signer, "fingerprint");
| ^~~~~~~~~~~
external_signer.cpp:41:49: note: the temporary was destroyed at the end of the full expression ‘find_value((* & signer), std::__cxx11::basic_string<char>(((const char*)"fingerprint"), std::allocator<char>()))’
41 | const UniValue& fingerprint = find_value(signer, "fingerprint");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
external_signer.cpp:53:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
53 | const UniValue& model_field = find_value(signer, "model");
| ^~~~~~~~~~~
external_signer.cpp:53:49: note: the temporary was destroyed at the end of the full expression ‘find_value((* & signer), std::__cxx11::basic_string<char>(((const char*)"model"), std::allocator<char>()))’
53 | const UniValue& model_field = find_value(signer, "model");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~
rpc/rawtransaction_util.cpp: In function ‘CMutableTransaction ConstructTransaction(const UniValue&, const UniValue&, const UniValue&, std::optional<bool>)’:
rpc/rawtransaction_util.cpp:55:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
55 | const UniValue& vout_v = find_value(o, "vout");
| ^~~~~~
rpc/rawtransaction_util.cpp:55:44: note: the temporary was destroyed at the end of the full expression ‘find_value((* & o), std::__cxx11::basic_string<char>(((const char*)"vout"), std::allocator<char>()))’
55 | const UniValue& vout_v = find_value(o, "vout");
| ~~~~~~~~~~^~~~~~~~~~~
rpc/rawtransaction_util.cpp:73:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
73 | const UniValue& sequenceObj = find_value(o, "sequence");
| ^~~~~~~~~~~
rpc/rawtransaction_util.cpp:73:49: note: the temporary was destroyed at the end of the full expression ‘find_value((* & o), std::__cxx11::basic_string<char>(((const char*)"sequence"), std::allocator<char>()))’
73 | const UniValue& sequenceObj = find_value(o, "sequence");
| ~~~~~~~~~~^~~~~~~~~~~~~~~
bitcoin-cli.cpp: In function ‘UniValue ConnectAndCallRPC(BaseRequestHandler*, const std::string&, const std::vector<std::__cxx11::basic_string<char> >&, const std::optional<std::__cxx11::basic_string<char> >&)’:
bitcoin-cli.cpp:853:33: warning: possibly dangling reference to a temporary [-Wdangling-reference]
853 | const UniValue& error = find_value(response, "error");
| ^~~~~
bitcoin-cli.cpp:853:51: note: the temporary was destroyed at the end of the full expression ‘find_value(response, std::__cxx11::basic_string<char>(((const char*)"error"), std::allocator<char>()))’
853 | const UniValue& error = find_value(response, "error");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
bitcoin-cli.cpp: In function ‘void ParseError(const UniValue&, std::string&, int&)’:
bitcoin-cli.cpp:881:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
881 | const UniValue& err_code = find_value(error, "code");
| ^~~~~~~~
bitcoin-cli.cpp:881:46: note: the temporary was destroyed at the end of the full expression ‘find_value((* & error), std::__cxx11::basic_string<char>(((const char*)"code"), std::allocator<char>()))’
881 | const UniValue& err_code = find_value(error, "code");
| ~~~~~~~~~~^~~~~~~~~~~~~~~
bitcoin-cli.cpp:882:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
882 | const UniValue& err_msg = find_value(error, "message");
| ^~~~~~~
bitcoin-cli.cpp:882:45: note: the temporary was destroyed at the end of the full expression ‘find_value((* & error), std::__cxx11::basic_string<char>(((const char*)"message"), std::allocator<char>()))’
882 | const UniValue& err_msg = find_value(error, "message");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
bitcoin-cli.cpp: In function ‘void GetWalletBalances(UniValue&)’:
bitcoin-cli.cpp:909:21: warning: possibly dangling reference to a temporary [-Wdangling-reference]
909 | const UniValue& wallets = find_value(listwallets, "result");
| ^~~~~~~
bitcoin-cli.cpp:909:41: note: the temporary was destroyed at the end of the full expression ‘find_value(listwallets, std::__cxx11::basic_string<char>(((const char*)"result"), std::allocator<char>()))’
909 | const UniValue& wallets = find_value(listwallets, "result");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bitcoin-cli.cpp:916:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
916 | const UniValue& balance = find_value(getbalances, "result")["mine"]["trusted"];
| ^~~~~~~
bitcoin-cli.cpp:916:86: note: the temporary was destroyed at the end of the full expression ‘(&(& find_value(getbalances, std::__cxx11::basic_string<char>(((const char*)"result"), std::allocator<char>())))->UniValue::operator[](std::__cxx11::basic_string<char>(((const char*)"mine"), std::allocator<char>())))->UniValue::operator[](std::__cxx11::basic_string<char>(((const char*)"trusted"), std::allocator<char>()))’
916 | const UniValue& balance = find_value(getbalances, "result")["mine"]["trusted"];
| ^
bitcoin-cli.cpp: In function ‘int CommandLineRPC(int, char**)’:
bitcoin-cli.cpp:1163:29: warning: possibly dangling reference to a temporary [-Wdangling-reference]
1163 | const UniValue& error{find_value(getnewaddress, "error")};
| ^~~~~
bitcoin-cli.cpp:1163:45: note: the temporary was destroyed at the end of the full expression ‘find_value(getnewaddress, std::__cxx11::basic_string<char>(((const char*)"error"), std::allocator<char>()))’
1163 | const UniValue& error{find_value(getnewaddress, "error")};
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitcoin-cli.cpp:1188:29: warning: possibly dangling reference to a temporary [-Wdangling-reference]
1188 | const UniValue& error = find_value(reply, "error");
| ^~~~~
bitcoin-cli.cpp:1188:47: note: the temporary was destroyed at the end of the full expression ‘find_value(reply, std::__cxx11::basic_string<char>(((const char*)"error"), std::allocator<char>()))’
1188 | const UniValue& error = find_value(reply, "error");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~
rpc/mining.cpp: In lambda function:
rpc/mining.cpp:606:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
606 | const UniValue& modeval = find_value(oparam, "mode");
| ^~~~~~~
rpc/mining.cpp:606:45: note: the temporary was destroyed at the end of the full expression ‘find_value((* & oparam), std::__cxx11::basic_string<char>(((const char*)"mode"), std::allocator<char>()))’
606 | const UniValue& modeval = find_value(oparam, "mode");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~
rpc/mining.cpp:619:29: warning: possibly dangling reference to a temporary [-Wdangling-reference]
619 | const UniValue& dataval = find_value(oparam, "data");
| ^~~~~~~
rpc/mining.cpp:619:49: note: the temporary was destroyed at the end of the full expression ‘find_value((* & oparam), std::__cxx11::basic_string<char>(((const char*)"data"), std::allocator<char>()))’
619 | const UniValue& dataval = find_value(oparam, "data");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~
rpc/mining.cpp:646:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
646 | const UniValue& aClientRules = find_value(oparam, "rules");
| ^~~~~~~~~~~~
rpc/mining.cpp:646:50: note: the temporary was destroyed at the end of the full expression ‘find_value((* & oparam), std::__cxx11::basic_string<char>(((const char*)"rules"), std::allocator<char>()))’
646 | const UniValue& aClientRules = find_value(oparam, "rules");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~
test/interfaces_tests.cpp: In member function ‘void interfaces_tests::findCommonAncestor::test_method()’:
test/interfaces_tests.cpp:101:19: warning: possibly dangling reference to a temporary [-Wdangling-reference]
101 | const CChain& active = WITH_LOCK(Assert(m_node.chainman)->GetMutex(), return Assert(m_node.chainman)->ActiveChain());
| ^~~~~~
In file included from ./util/system.h:21,
from ./test/util/setup_common.h:19,
from test/interfaces_tests.cpp:9:
./sync.h:302:96: note: the temporary was destroyed at the end of the full expression ‘<lambda closure object>interfaces_tests::findCommonAncestor::test_method()::<lambda()>{((interfaces_tests::findCommonAncestor*)this)}.interfaces_tests::findCommonAncestor::test_method()::<lambda()>()’
302 | #define WITH_LOCK(cs, code) (MaybeCheckNotHeld(cs), [&]() -> decltype(auto) { LOCK(cs); code; }())
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
test/interfaces_tests.cpp:101:28: note: in expansion of macro ‘WITH_LOCK’
101 | const CChain& active = WITH_LOCK(Assert(m_node.chainman)->GetMutex(), return Assert(m_node.chainman)->ActiveChain());
| ^~~~~~~~~
test/system_tests.cpp: In member function ‘void system_tests::run_command::test_method()’:
test/system_tests.cpp:48:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
48 | const UniValue& success = find_value(result, "success");
| ^~~~~~~
test/system_tests.cpp:48:45: note: the temporary was destroyed at the end of the full expression ‘find_value(result, std::__cxx11::basic_string<char>(((const char*)"success"), std::allocator<char>()))’
48 | const UniValue& success = find_value(result, "success");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
test/system_tests.cpp:96:25: warning: possibly dangling reference to a temporary [-Wdangling-reference]
96 | const UniValue& success = find_value(result, "success");
| ^~~~~~~
test/system_tests.cpp:96:45: note: the temporary was destroyed at the end of the full expression ‘find_value(result, std::__cxx11::basic_string<char>(((const char*)"success"), std::allocator<char>()))’
96 | const UniValue& success = find_value(result, "success");
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~