title: Passing non-lvalue as const reference argument. Is the temp created in local scope or caller scope?
body: <p>Ok, so, I already know that returning a local variable as reference will cause undefined behavior when we try to use it and that we can create a non-const reference to only form a lvalue variable. Creating a const reference does not need to be created from a lvalue variable, because if it is created from a non-lvalue variable, it creates a temporary one in that scope (code below).</p>
  
  <pre><code>const int&amp; refa {2};
  
  // basically equals
  const int temp_a{2};
  const int&amp; refa{temp_a};
  </code></pre>
  
  <p>And there goes my question, if we pass a non-lvalue as a parameter to a function that takes a const reference, will the temporary variable be created in local scope of the caller or in local scope of the function? I am curious if returning the argument as reference and using it will cause undefined behavior.
  Sample (assume that the method is not inline):</p>
  
  <pre><code>_declspec(noinline) const int&amp; inMax(const int&amp; a, const int&amp; b)
  {
       return a &gt; b ? a : b;
  }
  
  int main()
  {
      int a{ 5 }, b{ 6 };
  
      // Will the temporary variables for POST decrementation/incrementation result 
      // will be created here or inside inMax(...)
      const int&amp; ret = inMax(a++, b--);
      // is the ret safe to use?
  }
  </code></pre>