mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
delete operator and std::allocator are not necessarily the same
The unit test for StorageBasic tested the StealArray feature and then used the delete[] operator on the stolen array to deallocate it. For many standard libraries the default implementation for delete[] is the same as (or at least compatible with) std::allocator, but for the PGI compiler they were not compatible and this resulted in a run-time error. This change fixes the problem with the test by using the same allocator as the StorageBasic test.
This commit is contained in:
parent
d4ad846e65
commit
bc3e1ebd21
@ -52,7 +52,6 @@ public:
|
||||
typedef vtkm::cont::internal::ArrayPortalFromIterators<ValueType*> PortalType;
|
||||
typedef vtkm::cont::internal::ArrayPortalFromIterators<const ValueType*> PortalConstType;
|
||||
|
||||
private:
|
||||
/// The original design of this class provided an allocator as a template
|
||||
/// parameters. That messed things up, though, because other templated
|
||||
/// classes assume that the \c Storage has one template parameter. There are
|
||||
|
@ -72,7 +72,7 @@ struct TemplatedTests
|
||||
|
||||
StorageType stealMyArray;
|
||||
stealMyArray.Allocate(ARRAY_SIZE);
|
||||
SetStorage(stealMyArray, stolenArrayValue);
|
||||
this->SetStorage(stealMyArray, stolenArrayValue);
|
||||
|
||||
VTKM_TEST_ASSERT(stealMyArray.GetNumberOfValues() == ARRAY_SIZE,
|
||||
"Array not properly allocated.");
|
||||
@ -92,7 +92,8 @@ struct TemplatedTests
|
||||
VTKM_TEST_ASSERT(test_equal(stolenArray[index], stolenArrayValue),
|
||||
"Stolen array did not retain values.");
|
||||
}
|
||||
delete[] stolenArray;
|
||||
typename StorageType::AllocatorType allocator;
|
||||
allocator.deallocate(stolenArray, ARRAY_SIZE);
|
||||
}
|
||||
|
||||
void BasicAllocation()
|
||||
@ -106,8 +107,8 @@ struct TemplatedTests
|
||||
"Array not properly allocated.");
|
||||
|
||||
const ValueType BASIC_ALLOC_VALUE = ValueType(48);
|
||||
SetStorage(arrayStorage, BASIC_ALLOC_VALUE);
|
||||
VTKM_TEST_ASSERT(CheckStorage(arrayStorage, BASIC_ALLOC_VALUE),
|
||||
this->SetStorage(arrayStorage, BASIC_ALLOC_VALUE);
|
||||
VTKM_TEST_ASSERT(this->CheckStorage(arrayStorage, BASIC_ALLOC_VALUE),
|
||||
"Array not holding value.");
|
||||
|
||||
arrayStorage.Allocate(ARRAY_SIZE * 2);
|
||||
|
Loading…
Reference in New Issue
Block a user