const reference data member bound to a temporary initializing that reference in a constructor
<p>Consider the following code:</p>

<pre><code>#include &lt;iostream&gt;

struct A {
    const char *name;

    A() : name("A") {
        std::cout &lt;&lt; "A()\n";
    }

    virtual ~A() {
        std::cout &lt;&lt; "~A()\n";
    }
};

class B {
    const A&amp; a;
public:

    B() : a(A()) {
    };

    void print_data() const {
        std::cout &lt;&lt; a.name &lt;&lt; '\n';
    }

    ~B() {
        std::cout &lt;&lt; "~B()\n";
    }
};

int main() {
    B b;
    b.print_data();
    return 0;
}
</code></pre>

<p>The output from GCC 4.4 is:</p>

<blockquote>
  <p>A()  ~A()  A ~B()</p>
</blockquote>

<p>This looks strange to me. I would have expected either a copy of the temporary instance of A being bound to the B::a or that temporary itself being destructed during ~B().</p>

<p>Basically, I thought B::a is always a valid reference during the life of b. In fact b.print_data() works apparently and the compiler does not give any warning. </p>

<p>What does the standard c++98/03 say about this matter?</p>
