title: Creating a local vector inside a function, then pass it as a reference to other functions which store it as a reference
body: <p>Is there any potential danger in this code?</p>
  
  <pre><code>void f(){
      std::vector&lt;int&gt; v;
      ...
      g(v);
  }
  
  void g(std::vector&lt;int&gt; &amp;a){
      ... //store a by reference in variable blah (global)
  }
  </code></pre>
  
  <p>v is destroyed when the call to f() is finished, but blah will still be referencing to v. Will blah become invalid? Is there a better way to do this while not making unnecessary copies of the vector? </p>