[Bug c++/57510] initializer_list memory leak

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 3 13:09:00 GMT 2013


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-06-03
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Testcase without <memory and <random> and not requiring valgrind:

#include <initializer_list>

struct counter
{
  static int n;

  counter() { ++n; }
  counter(const counter&) { ++n; }
  ~counter() { --n; }
};

int counter::n = 0;

struct X
{
    X () { if (counter::n > 1) throw 1; }

    counter c;
};

int main ()
{
  try
  {
    auto x = { X{}, X{} };
  }
  catch (...)
  {
    if ( counter::n != 0 )
      throw;
  }
}



More information about the Gcc-bugs mailing list