From acf88ae62167d8d4b832b867ba24341ef8467ab9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 22 May 2002 18:04:36 +0000 Subject: [PATCH] added a compile time assert to prevent wxArray from compiling when sizeof(long) > sizeof(void *) as it is broken in this case git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15637 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dynarray.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/dynarray.cpp b/src/common/dynarray.cpp index 61400eddf8..25a7b4a31d 100644 --- a/src/common/dynarray.cpp +++ b/src/common/dynarray.cpp @@ -33,6 +33,11 @@ #define max(a, b) (((a) > (b)) ? (a) : (b)) #endif +// we cast the value to long from which we cast it to void * in IndexForInsert: +// this can't work if the pointers are not big enough +wxCOMPILE_TIME_ASSERT( sizeof(long) <= sizeof(void *), + wxArraySizeOfPtrLessSizeOfLong ); // < 32 symbols + // ============================================================================ // constants // ============================================================================ @@ -219,7 +224,8 @@ size_t name::IndexForInsert(T lItem, CMPFUNC fnCompare) const \ while ( lo < hi ) { \ i = (lo + hi)/2; \ \ - res = (*fnCompare)((const void *)lItem, (const void *)(m_pItems[i])); \ + res = (*fnCompare)((const void *)(long)lItem, \ + (const void *)(long)(m_pItems[i])); \ if ( res < 0 ) \ hi = i; \ else if ( res > 0 ) \ -- 2.45.2