mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix numerous pointer-to-integer conversion warnings in unit tests.
This commit is contained in:
@@ -22,7 +22,7 @@ void check_handmade_aligned_malloc()
|
||||
for(int i = 1; i < 1000; i++)
|
||||
{
|
||||
char *p = (char*)internal::handmade_aligned_malloc(i);
|
||||
VERIFY(size_t(p)%ALIGNMENT==0);
|
||||
VERIFY(internal::UIntPtr(p)%ALIGNMENT==0);
|
||||
// if the buffer is wrongly allocated this will give a bad write --> check with valgrind
|
||||
for(int j = 0; j < i; j++) p[j]=0;
|
||||
internal::handmade_aligned_free(p);
|
||||
@@ -34,7 +34,7 @@ void check_aligned_malloc()
|
||||
for(int i = ALIGNMENT; i < 1000; i++)
|
||||
{
|
||||
char *p = (char*)internal::aligned_malloc(i);
|
||||
VERIFY(size_t(p)%ALIGNMENT==0);
|
||||
VERIFY(internal::UIntPtr(p)%ALIGNMENT==0);
|
||||
// if the buffer is wrongly allocated this will give a bad write --> check with valgrind
|
||||
for(int j = 0; j < i; j++) p[j]=0;
|
||||
internal::aligned_free(p);
|
||||
@@ -46,7 +46,7 @@ void check_aligned_new()
|
||||
for(int i = ALIGNMENT; i < 1000; i++)
|
||||
{
|
||||
float *p = internal::aligned_new<float>(i);
|
||||
VERIFY(size_t(p)%ALIGNMENT==0);
|
||||
VERIFY(internal::UIntPtr(p)%ALIGNMENT==0);
|
||||
// if the buffer is wrongly allocated this will give a bad write --> check with valgrind
|
||||
for(int j = 0; j < i; j++) p[j]=0;
|
||||
internal::aligned_delete(p,i);
|
||||
@@ -58,7 +58,7 @@ void check_aligned_stack_alloc()
|
||||
for(int i = ALIGNMENT; i < 400; i++)
|
||||
{
|
||||
ei_declare_aligned_stack_constructed_variable(float,p,i,0);
|
||||
VERIFY(size_t(p)%ALIGNMENT==0);
|
||||
VERIFY(internal::UIntPtr(p)%ALIGNMENT==0);
|
||||
// if the buffer is wrongly allocated this will give a bad write --> check with valgrind
|
||||
for(int j = 0; j < i; j++) p[j]=0;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ template<typename T> void check_dynaligned()
|
||||
{
|
||||
T* obj = new T;
|
||||
VERIFY(T::NeedsToAlign==1);
|
||||
VERIFY(size_t(obj)%ALIGNMENT==0);
|
||||
VERIFY(internal::UIntPtr(obj)%ALIGNMENT==0);
|
||||
delete obj;
|
||||
}
|
||||
}
|
||||
@@ -148,15 +148,15 @@ void test_dynalloc()
|
||||
}
|
||||
|
||||
{
|
||||
MyStruct foo0; VERIFY(size_t(foo0.avec.data())%ALIGNMENT==0);
|
||||
MyClassA fooA; VERIFY(size_t(fooA.avec.data())%ALIGNMENT==0);
|
||||
MyStruct foo0; VERIFY(internal::UIntPtr(foo0.avec.data())%ALIGNMENT==0);
|
||||
MyClassA fooA; VERIFY(internal::UIntPtr(fooA.avec.data())%ALIGNMENT==0);
|
||||
}
|
||||
|
||||
// dynamic allocation, single object
|
||||
for (int i=0; i<g_repeat*100; ++i)
|
||||
{
|
||||
MyStruct *foo0 = new MyStruct(); VERIFY(size_t(foo0->avec.data())%ALIGNMENT==0);
|
||||
MyClassA *fooA = new MyClassA(); VERIFY(size_t(fooA->avec.data())%ALIGNMENT==0);
|
||||
MyStruct *foo0 = new MyStruct(); VERIFY(internal::UIntPtr(foo0->avec.data())%ALIGNMENT==0);
|
||||
MyClassA *fooA = new MyClassA(); VERIFY(internal::UIntPtr(fooA->avec.data())%ALIGNMENT==0);
|
||||
delete foo0;
|
||||
delete fooA;
|
||||
}
|
||||
@@ -165,8 +165,8 @@ void test_dynalloc()
|
||||
const int N = 10;
|
||||
for (int i=0; i<g_repeat*100; ++i)
|
||||
{
|
||||
MyStruct *foo0 = new MyStruct[N]; VERIFY(size_t(foo0->avec.data())%ALIGNMENT==0);
|
||||
MyClassA *fooA = new MyClassA[N]; VERIFY(size_t(fooA->avec.data())%ALIGNMENT==0);
|
||||
MyStruct *foo0 = new MyStruct[N]; VERIFY(internal::UIntPtr(foo0->avec.data())%ALIGNMENT==0);
|
||||
MyClassA *fooA = new MyClassA[N]; VERIFY(internal::UIntPtr(fooA->avec.data())%ALIGNMENT==0);
|
||||
delete[] foo0;
|
||||
delete[] fooA;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user