This is a new thread related to aligned memory management C++ operators 'new' / 'delete' and 'new' / 'delete'.
Please take a look at a similar thread:
Forum topic: 'Aligning with new: for a beginner'
Thanks to a User 'llevrel' for that subject!
PS: This is the first post and many more will follow...
Sergey Kostrov wrote:The size of the structure need not be a power of 2. The size of the structure needs to be a multiple of the power of 2 that you require for alignment (e.g. 8-bytes for doubles, 16 -bytes for SSE, or 32-bytes for AVX2, ...) I tested with Intel C++, I did not test with MSVC **** Potential gotcha *** In the new operator, the Intel compiler generates a size_t header element containing the count of the elements in the array. Thus the necessitating of creating of the prefix padd in the allocation, and the bung-up (fix-up) of the returned pointer (converse in the delete operator). *** this value may change from compiler vendor to compiler vendor *** Therfore it is a requirement that you run a verification program, such as the provided test program, then make adjustments (conditional compilations) as required. You will note that you will need to do this in any event because the VTable information may vary from vendor to vendor. You might consider keeping a verification test in the beginning of the program in the event that a library function (.DLL, .so) returns the new. The information (diagnostic) may be more helpful than a GP fault in determining the problem. Jim Dempsey
This is a limitation of '_aligned_offset_malloc_dbg' CRT-function and it always uses IS_2_POW_N( align ) macro. If somebody wants to create an object on any alignment boundary value then a new function could be created based on '_aligned_offset_malloc_dbg' CRT-function but without _VALIDATE_RETURN and IS_2_POW_N macros.
Sergey Kostrov wrote:It should be easy enough to overload the missing funcitons. Jim Dempsey
Just discovered that
CRT-functions are NOT supported on Windows Mobile platforms.