Are function return values automatic objects and thus guaranteed to be destructed?
<p>In [except.ctor] the standard (<a href="https://stackoverflow.com/questions/81656/where-do-i-find-the-current-c-or-c-standard-documents">N4140</a>) guarantees that:</p>

<blockquote>
  <p>...destructors are invoked for
  all automatic objects constructed since the try block was
  entered...</p>
</blockquote>

<p>However in the following example the empty <a href="http://coliru.stacked-crooked.com/a/1dd0994a6102b75e" rel="nofollow noreferrer">output</a> proves that the return value of function <code>foo</code> is not destructed, although it has been constructed. Compiled using g++ (5.2.1) and clang++ (3.6.2-1) and with options <code>-O0 -fno-elide-constructors -std=c++14</code>. </p>

<pre><code>struct A { ~A() { cout &lt;&lt; "~A\n"; } };

struct B { ~B() noexcept(false) { throw 0; } };

A foo() {
  B b;
  return {};
}

int main() {
  try { foo(); }
  catch (...) { }
}
</code></pre>

<p>Is this a bug both in g++ and clang++, or are function return values not
considered automatic objects, or is it a loop hole in the C++ language?</p>

<p>In none of [stmt.return], [expr.call] or [dcl.fct] I have been able to find
a clear statement whether a function return value is considered an automatic
object. The closest hints I found are 6.3.3 p2:</p>

<blockquote>
  <p>...A return statement can
  involve the construction and copy or move of a temporary object...</p>
</blockquote>

<p>and 5.2.2 p10:</p>

<blockquote>
  <p>A function call is an lvalue if the result type is an lvalue
  reference type or an rvalue reference to function type, an xvalue if the
  result type is an rvalue reference to object type, and a prvalue otherwise.</p>
</blockquote>