Hei,
I am trying to compile the following code
#include <memory>
#include <algorithm>
// Check the version language macro, but skip MSVC because
// MSVC reports 199711 even in MSVC 2017.
#if __cplusplus < 201402L && !defined(_MSC_VER) && !defined(__INTEL_COMPILER)
#error "insufficient support for C++14"
#endif
int main(){
auto ptr = std::make_unique<int>(42);
constexpr int max = std::max(0, 1);
(void) ptr;
(void) max;
return 0;
}
with the latest intel-compiler (icpc version 2021.4.0 (gcc version 11.2.1 compatibility)) using icpc -std=c++14, running on OpenSUSE Tumbleweed, but it fails with the following error:
In file included from /usr/include/c++/11/cwchar(44),
from /usr/include/c++/11/bits/postypes.h(40),
from /usr/include/c++/11/iosfwd(40),
from /usr/include/c++/11/bits/shared_ptr.h(52),
from /usr/include/c++/11/memory(77),
from test.cpp(1):
/usr/include/wchar.h(155): error: attribute "__malloc__" does not take arguments
__attribute_malloc__ __attr_dealloc_free;
^
In file included from /usr/include/c++/11/cstdlib(75),
from /usr/include/c++/11/bits/stl_algo.h(59),
from /usr/include/c++/11/algorithm(62),
from test.cpp(2):
/usr/include/stdlib.h(565): error: attribute "__malloc__" does not take arguments
__attr_dealloc_free;
^
In file included from /usr/include/c++/11/cstdlib(75),
from /usr/include/c++/11/bits/stl_algo.h(59),
from /usr/include/c++/11/algorithm(62),
from test.cpp(2):
/usr/include/stdlib.h(569): error: attribute "__malloc__" does not take arguments
__THROW __attr_dealloc (reallocarray, 1);
^
In file included from /usr/include/c++/11/cstdlib(75),
from /usr/include/c++/11/bits/stl_algo.h(59),
from /usr/include/c++/11/algorithm(62),
from test.cpp(2):
/usr/include/stdlib.h(797): error: attribute "__malloc__" does not take arguments
__attr_dealloc_free __wur;
^
compilation aborted for test.cpp (code 2)
In comparison, g++ (gcc-Version 11.2.1 20210816) works fine. What can I do to compile the code piece with icpc, too?
連結已複製
Hi,
Thanks for reaching out to us.
We have tried compiling and executing the shared code using icpc 2021.4 and it runs fine.
We have used below command to compile the code.
icpc -std=c++14<filename>
Below are our environment details.
Operating System: Ubuntu 18.04.3 LTS
Kernel: Linux 4.15.0-76-generic
For compatibility, Kindly refer the link for Intel® C++ Compiler Classic System Requirements
Best Regards,
Shanmukh.SS
Hei,
I tried again, but failed. As far as I can see it might be related to a new feature in GCC11 (https://gcc.gnu.org/onlinedocs/gcc-11.1.0/gcc/Common-Function-Attributes.html#index-malloc-function-attribute, https://gcc.gnu.org/gcc-11/changes.html#c-family), which allows malloc to have attributes. Is that function supported by the Intel compiler?
Thanks!
Hi,
We would like to inform you that the gcc versions supported for ICC are between 4.8 - 9.2 and the query was regarding the gcc version 11.2.1. In addition, the list of supported OS are available in the link shared below.
Best Regards,
Shanmukh.SS
Hei,
switching to those GCC-versions is not possible for me. Moreover, the issue seems to lie in glibc 2.34 which uses exactly that function. GCC 11.x supports it, but LLVM/Clang 13 do not (https://githubplus.com/bradking). Moreover, nvcc seems to have the same issue: https://forums.developer.nvidia.com/t/cuda-11-5-samples-throw-multiple-error-attribute-malloc-does-not-take-arguments/192750
Therefore, I decided to drop ICC until an update will be available which fixes this error.
Thanks for the help!
Hi,
We are closing this thread assuming your issue has been resolved. We will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread.
Best Regards,
Shanmukh.SS