# std::move and local variable address

**URL:** https://discourse.kitware.com/t/std-move-and-local-variable-address/400
**Category:** Using SMTK
**Created:** [January 29, 2020, 7:44pm UTC](https://discourse.kitware.com/t/std-move-and-local-variable-address/400 "2020-01-29T19:44:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![aron.helser](https://discourse.kitware.com/user_avatar/discourse.kitware.com/aron.helser/32/149_2.png) [@aron.helser](https://discourse.kitware.com/u/aron.helser)
#### Post date: [January 29, 2020, 7:44pm UTC](https://discourse.kitware.com/t/std-move-and-local-variable-address/400/1 "2020-01-29T19:44:24Z")

</div>

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()));

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.kitware.com/u/ben.boeckel)
#### Post date: [January 30, 2020, 2:41pm UTC](https://discourse.kitware.com/t/std-move-and-local-variable-address/400/2 "2020-01-30T14:41:27Z")

</div>

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

---

<div class="post-metadata">

### Author: ![aron.helser](https://discourse.kitware.com/user_avatar/discourse.kitware.com/aron.helser/32/149_2.png) [@aron.helser](https://discourse.kitware.com/u/aron.helser)
#### Post date: [January 30, 2020, 3:03pm UTC](https://discourse.kitware.com/t/std-move-and-local-variable-address/400/3 "2020-01-30T15:03:24Z")

</div>

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());
}
```
