http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48281

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> 2011-03-30 
16:01:21 UTC ---
This was broken by r163893, when I changed finish_compound_literal to always
generate a TARGET_EXPR, rather than use a static variable in some cases.

I could (and probably will) partially revert that to fix this testcase, but
looking into it reveals a deeper bug: we are generally failing to extend the
lifetime of temporaries except in the simplest cases.  In this C++98 testcase
we bind a temporary to the reference member of C, but don't extend its lifetime
as we should.  This is probably pretty rare, but initializer_list subobjects
are likely to be more common.

extern "C" void abort();
bool ok;

struct A {
  A(int) { }
  ~A() { if (!ok) abort(); }
};

struct C
{ 
  const A& ar;
};

int main()
{
  C c = { 1 };
  ok = true;
}

Reply via email to