Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

Compilation issues with ICPC 2021.4 and C++14

arc_lupo
초급자
14,376 조회수

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?

0 포인트
12 응답
ShanmukhS_Intel
중재자
14,317 조회수

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


https://software.intel.com/content/www/us/en/develop/articles/oneapi-c-compiler-system-requirements.html


Best Regards,

Shanmukh.SS


0 포인트
ShanmukhS_Intel
중재자
14,248 조회수

Hi,


Reminder:

Has the solution provided helped? Please let us know if the issue still persists.


Best Regards,

Shanmukh.SS


0 포인트
arc_lupo
초급자
14,226 조회수

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!

0 포인트
ShanmukhS_Intel
중재자
14,097 조회수

Hi,

 

It seems issue is because of the OpenSUSE Tumbleweed currently you are working on. We have tried compiling and running the code on 11.1.0 as well and it compiles and runs fine. Attached the screenshot for your reference.

 

Best Regards,

Shanmukh.SS

 

0 포인트
ShanmukhS_Intel
중재자
13,943 조회수

Hi,

 

Reminder:

Has the information provided helped? Please let us know if the issue still persists.

 

Best Regards,

Shanmukh.SS

 

0 포인트
arc_lupo
초급자
13,932 조회수

Hei,

no, the issue still persists, and short of changing the OS I did not find a solution yet.

Regards

0 포인트
ShanmukhS_Intel
중재자
13,834 조회수

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.

https://www.intel.com/content/www/us/en/developer/articles/system-requirements/oneapi-c-compiler-system-requirements.html

 

Best Regards,
Shanmukh.SS

 

0 포인트
ShanmukhS_Intel
중재자
13,749 조회수

Hi,

 

Reminder:

Has the information provided helped? We would like to recommend you to try with the supported gcc versions as mentioned.


Best Regards,

Shanmukh.SS


0 포인트
arc_lupo
초급자
13,748 조회수

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!

0 포인트
Viet_H_Intel
중재자
13,637 조회수

This is a known issue and will be fixed in the future releases. Please check back once we have a new release.


Thanks,



0 포인트
ShanmukhS_Intel
중재자
13,097 조회수

Hi,


Thank you for your patience. The issue raised by you has been fixed in 2022.1 version. Could you please download it and let us know if this resolves your issue.


Best Regards,

Shanmukh.SS


0 포인트
ShanmukhS_Intel
중재자
12,970 조회수

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


0 포인트
응답