std::move and local variable address

What is this warning trying to tell me?

/home/aron.helser/projects/cmb/plugin-rgg-session/src/smtk/session/rgg/qt/rggNucAssembly.cxx: In member function ‘const smtk::model::EntityRef& rggNucAssembly::getAssyDuct() const’:
/home/aron.helser/projects/cmb/plugin-rgg-session/src/smtk/session/rgg/qt/rggNucAssembly.cxx:218:79: warning: function may return address of local variable [-Wreturn-local-addr]
return std::move(smtk::model::EntityRef(m_resource, m_assy.associatedDuct()));
^
/home/aron.helser/projects/cmb/plugin-rgg-session/src/smtk/session/rgg/qt/rggNucAssembly.cxx:218:78: note: declared here
return std::move(smtk::model::EntityRef(m_resource, m_assy.associatedDuct()));

The std::move seems redundant to me. RVO should handle this case.

Seems like returning a const reference here is sketchy - and it’s not actually referenced anywhere. I’ll just remove it completely.

smtk::model::EntityRef const& rggNucAssembly::getAssyDuct() const
{
  return std::move(smtk::model::EntityRef(m_resource, m_assy.associatedDuct()));
}

smtk::model::EntityRef rggNucAssembly::getAssyDuct()
{
  return smtk::model::EntityRef(m_resource, m_assy.associatedDuct());
}
Privacy Notice