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:
parent
d0f195d8c2
commit
7967f6270d
1 changed files with 1 additions and 1 deletions
|
|
@ -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(); }
|
||||
|
|
|
|||
Loading…
Reference in a new issue