Given the following code:

class foo
{
};

class bar: public foo
{
public: 
    ~bar() { printf("~bar()\n"); }
};

class zab: public foo
{
public: 
    ~zab() { printf("~zab()\n"); }
};

struct foo_holder
{
    const foo &f;
};

int main()
{
    foo_holder holder[]= { {bar()}, {zab()} };
    printf("done!\n");
    return 0;
}

the output is:

~bar()
~zab()
done!

C++0x has a clause that dictates this can create dangling references when used as a new initializer, but it says nothing (at least nothing I can find) about aggregate initialization of const references with temporaries.

Is this unspecified behavior then?

Edit
Report