Older compilers seem to let this slide, but newer compilers (for example clang v8) rightly
complain about this sort of thing:
std::pair<const std::string &, Node &> Iterator::operator *()
{
switch(m_Type)
{
case SequenceType:
return {"", *(static_cast<SequenceIteratorImp*>(m_pImp)->m_Iterator->second)};
// ^---- reference member 'first' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object
break;
...
That string literal is going to make a temporary std::string, which will destruct when the function returns. The problem occurs at Yaml.cpp:720 and Yaml.cpp:871.
Older compilers seem to let this slide, but newer compilers (for example clang v8) rightly complain about this sort of thing:
That string literal is going to make a temporary
std::string
, which will destruct when the function returns. The problem occurs atYaml.cpp:720
andYaml.cpp:871
.