bugfix: don't call the dtor on failed objects

When a ctor throws, the dtors of sub-objects have already been
invoked. The object itself never existed, strictly speaking,
and thus the dtor must not be invoked. Usually the runtime system
handles matters automatically this way, but since we're doing
here placement new into an array, we're responsible ourselves

This error was uncovered by compiling with Clang.
GCC automatically neutralised this erroneous dtor invocation.
This commit is contained in:
Fischlurch 2013-10-21 05:17:59 +02:00
parent d0f195d8c2
commit 7967f6270d

View file

@ -143,7 +143,7 @@ namespace lib {
while (i<n)
factory(&array_[i++]);
}
catch(...) { cleanup(i); throw; }
catch(...) { cleanup(i-1); throw; } // destroy finished part, without the failed object
}
~RefArrayTable() { cleanup(); }