BitMap has a trivial copy constructor and assignment operator. As a result, making a copy will just make a new reference to the data buffer.
This means that all copies of a BitMap share the same data buffer, so modifying one modifies all copies. That seems a surprising result for copying, and might not be what's intended.
This also causes problems for lifetime management of the data buffer:
All BitMap constructors specify false for the allocator's free_in_destructor argument. That's fine for a BitMap using resource-based allocation. It also works for a BitMap that was constructed from an externally supplied buffer and didn't have a resizing operation performed. However, it means that other uses of BitMap will leak the buffer.
This means that all copies of a BitMap share the same data buffer, so modifying one modifies all copies. That seems a surprising result for copying, and might not be what's intended.
This also causes problems for lifetime management of the data buffer:
All BitMap constructors specify false for the allocator's free_in_destructor argument. That's fine for a BitMap using resource-based allocation. It also works for a BitMap that was constructed from an externally supplied buffer and didn't have a resizing operation performed. However, it means that other uses of BitMap will leak the buffer.
- is blocked by
-
JDK-8141496 BitMap set operations copy their other BitMap argument
-
- Resolved
-