The documentation for _alloca()
says here:
The _alloca routine returns a void pointer to the allocated space, which is guaranteed to be suitably aligned for storage of any type of object.
However, here it says:
_alloca is required to be 16-byte aligned and additionally required to use a frame pointer.
So it seems that in the first reference they forgot about 32-byte aligned AVX/AVX2 types like __m256d
.
Another thing that confuses me is that the first page says _alloca()
is deprecated, while it suggests to use instead a function that may allocate memory from the heap rather than the stack (which is unacceptable in my multi-threaded application).
So can someone point me whether there is some modern (perhaps, new C/C++ standard?) way for aligned stack memory allocation?
Clarification 1: Please, don't provide solutions which require the array size to be compile-time constant. My function allocates variable number of array items depending on run-time parameter value.