-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<deque>: For allocators where allocator_traits<T>::pointer is an object, destructors aren't always called #2769
Comments
I believe that this is clearly a bug - thanks for the report! Over time, we overhauled |
I don't know how to properly solve it, but to save some debugging effort, I think this is at least one issue: all the block pointers in the map are constructed, even if they're empty, but are only destroyed if they're non-empty. The map size in this example is 8, so the pointer to the one used block gets destroyed and the other 7 don't. Lines 1486 to 1495 in 17fde2c
|
Do we want to fix this by ensuring that all pointers are constructed and destroyed via the allocator, or do we want to really fix it by never constructing nor destroying any pointers via the allocator as the Standard requires? |
The call to |
We talked about this at the weekly maintainer meeting and we believe that it should be safe to fix this to follow the Standardese - we should use |
On that part @CaseyCarter is right (edit: right that there's a bug, I mean). I noticed during debugging that the allocator is also used for the map and the container proxy: Lines 587 to 593 in 17fde2c
Lines 1442 to 1455 in 17fde2c
etc. |
We need to allocate the map and the proxy with the user-provided allocator (as all persistent allocations must respect this) - it's |
Ah, I was pretty sure I was missing something. Thanks. |
When using a custom allocator that defines
allocator_traits<T>::pointer
as a class or struct,std::deque
constructs more instances of thatpointer
object than it destroys. So ifpointer
has non-trivial constructors or destructors, some destructors will not be called.Results
FancyPointer
has a counter in the constructor and destructor to count the number of live instances. After thedeque
has been destroyed, the counter should be zero, showing that allFancyPointer
destructors have run correctly. However, the program outputs '7'. Ifstd::deque
in the above program is replaced withstd::list
orstd::vector
, the program will output '0' as expected.STL version
Microsoft Visual Studio Enterprise 2022 (64-bit) - Preview
Version 17.3.0 Preview 1.1
The text was updated successfully, but these errors were encountered: