Skip to content
Advertisement

icpc error in compiling over-aligned dynamic allocated variables

I am trying to compile a code in C++, that uses over-aligned variables. If I try to compile the following code (a MWE)

JavaScript

everything runs smoothly if I use icpx or g++ (in all the cases, the flag -std=c++17 is given to the compiler). However, when compiling using Intel icpc, I got the following error

JavaScript

and I do not understand what the error can be. How can I solve this issue?

Advertisement

Answer

It seems that icpc fails to conform with the standard with aligned allocations. Quoting from the documentations for version 2021.5:

In this release of the compiler, all that is necessary in order to get correct dynamic allocation for aligned data is to include a new header:

#include <aligned_new>

After this header is included, a new-expression for any aligned type will automatically allocate memory with the alignment of that type.

Link: https://www.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/optimization-and-programming-guide/automatically-aligned-dynamic-allocation/automatically-aligned-dynamic-allocation-1.html

Live demo: https://godbolt.org/z/5xMqKGrTG

This section is missing in the documentation of icpx: https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top.html.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement