Reputation: 9
When I use icc compiler to compile a simple c++ code in Fedora 26 linux system, it caused an error like belows:
icc command:
icpc test.cpp
test.cpp content:
#include<iostream>
using namespace std;
int main() {
cout<<"hello world" << endl;
return 0;
}
it caused an error like:
/usr/include/c++/7/bits/move.h(48): error: identifier "__builtin_addressof" is undefined
{ return __builtin_addressof(__r); }
^
detected during:
instantiation of "_Tp *std::__addressof(_Tp &) [with _Tp=std::__make_not_void<char>={char}]" at line 138
instantiation of "_Tp *std::addressof(_Tp &) [with _Tp=std::__make_not_void<char>={char}]" at line 142 of "/usr/include/c++/7/bits/ptr_traits.h"
instantiation of "std::pointer_traits<_Tp *>::pointer std::pointer_traits<_Tp *>::pointer_to(std::__make_not_void<std::pointer_traits<_Tp *>::element_type> &) [with _Tp=char]" at line 166 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_local_data() [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" at line 485 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT *, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc &) [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" at line 6473 of "/usr/include/c++/7/bits/basic_string.h"
/usr/include/c++/7/bits/move.h(48): error: identifier "__builtin_addressof" is undefined
{ return __builtin_addressof(__r); }
^
detected during:
instantiation of "_Tp *std::__addressof(_Tp &) [with _Tp=std::__make_not_void<const char>={const char}]" at line 138
instantiation of "_Tp *std::addressof(_Tp &) [with _Tp=std::__make_not_void<const char>={const char}]" at line 142 of "/usr/include/c++/7/bits/ptr_traits.h"
instantiation of "std::pointer_traits<_Tp *>::pointer std::pointer_traits<_Tp *>::pointer_to(std::__make_not_void<std::pointer_traits<_Tp *>::element_type> &) [with _Tp=const char]" at line 176 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_local_data() const [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" at line 195 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "bool std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_is_local() const [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" at line 204 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_dispose() [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" at line 228 of "/usr/include/c++/7/bits/basic_string.tcc"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct(_FwdIterator, _FwdIterator, std::forward_iterator_tag) [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>, _FwdIterator=const char *]" at line 220 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct_aux(_InIterator, _InIterator, std::__false_type) [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>, _InIterator=const char *]" at line 239 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct(_InIterator, _InIterator) [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>, _InIterator=const char *]" at line 486 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT *, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc &) [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" at line 6473 of "/usr/include/c++/7/bits/basic_string.h"
/usr/include/c++/7/bits/move.h(48): error: identifier "__builtin_addressof" is undefined
{ return __builtin_addressof(__r); }
^
detected during:
instantiation of "_Tp *std::__addressof(_Tp &) [with _Tp=std::__make_not_void<wchar_t>={wchar_t}]" at line 138
instantiation of "_Tp *std::addressof(_Tp &) [with _Tp=std::__make_not_void<wchar_t>={wchar_t}]" at line 142 of "/usr/include/c++/7/bits/ptr_traits.h"
instantiation of "std::pointer_traits<_Tp *>::pointer std::pointer_traits<_Tp *>::pointer_to(std::__make_not_void<std::pointer_traits<_Tp *>::element_type> &) [with _Tp=wchar_t]" at line 166 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_local_data() [with _CharT=wchar_t, _Traits=std::char_traits<wchar_t>, _Alloc=std::allocator<wchar_t>]" at line 485 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT *, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc &) [with _CharT=wchar_t, _Traits=std::char_traits<wchar_t>, _Alloc=std::allocator<wchar_t>]" at line 6479 of "/usr/include/c++/7/bits/basic_string.h"
/usr/include/c++/7/bits/move.h(48): error: identifier "__builtin_addressof" is undefined
{ return __builtin_addressof(__r); }
^
detected during:
instantiation of "_Tp *std::__addressof(_Tp &) [with _Tp=std::__make_not_void<const wchar_t>={const wchar_t}]" at line 138
instantiation of "_Tp *std::addressof(_Tp &) [with _Tp=std::__make_not_void<const wchar_t>={const wchar_t}]" at line 142 of "/usr/include/c++/7/bits/ptr_traits.h"
instantiation of "std::pointer_traits<_Tp *>::pointer std::pointer_traits<_Tp *>::pointer_to(std::__make_not_void<std::pointer_traits<_Tp *>::element_type> &) [with _Tp=const wchar_t]" at line 176 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_local_data() const [with _CharT=wchar_t, _Traits=std::char_traits<wchar_t>, _Alloc=std::allocator<wchar_t>]" at line 195 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "bool std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_is_local() const [with _CharT=wchar_t, _Traits=std::char_traits<wchar_t>, _Alloc=std::allocator<wchar_t>]" at line 204 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_dispose() [with _CharT=wchar_t, _Traits=std::char_traits<wchar_t>, _Alloc=std::allocator<wchar_t>]" at line 228 of "/usr/include/c++/7/bits/basic_string.tcc"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct(_FwdIterator, _FwdIterator, std::forward_iterator_tag) [with _CharT=wchar_t, _Traits=std::char_traits<wchar_t>, _Alloc=std::allocator<wchar_t>, _FwdIterator=const wchar_t *]" at line 220 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct_aux(_InIterator, _InIterator, std::__false_type) [with _CharT=wchar_t, _Traits=std::char_traits<wchar_t>, _Alloc=std::allocator<wchar_t>, _InIterator=const wchar_t *]" at line 239 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct(_InIterator, _InIterator) [with _CharT=wchar_t, _Traits=std::char_traits<wchar_t>, _Alloc=std::allocator<wchar_t>, _InIterator=const wchar_t *]" at line 486 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT *, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc &) [with _CharT=wchar_t, _Traits=std::char_traits<wchar_t>, _Alloc=std::allocator<wchar_t>]" at line 6479 of "/usr/include/c++/7/bits/basic_string.h"
/usr/include/c++/7/bits/move.h(48): error: identifier "__builtin_addressof" is undefined
{ return __builtin_addressof(__r); }
^
detected during:
instantiation of "_Tp *std::__addressof(_Tp &) [with _Tp=std::__make_not_void<char16_t>={char16_t}]" at line 138
instantiation of "_Tp *std::addressof(_Tp &) [with _Tp=std::__make_not_void<char16_t>={char16_t}]" at line 142 of "/usr/include/c++/7/bits/ptr_traits.h"
instantiation of "std::pointer_traits<_Tp *>::pointer std::pointer_traits<_Tp *>::pointer_to(std::__make_not_void<std::pointer_traits<_Tp *>::element_type> &) [with _Tp=char16_t]" at line 166 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_local_data() [with _CharT=char16_t, _Traits=std::char_traits<char16_t>, _Alloc=std::allocator<char16_t>]" at line 485 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT *, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc &) [with _CharT=char16_t, _Traits=std::char_traits<char16_t>, _Alloc=std::allocator<char16_t>]" at line 6486 of "/usr/include/c++/7/bits/basic_string.h"
/usr/include/c++/7/bits/move.h(48): error: identifier "__builtin_addressof" is undefined
{ return __builtin_addressof(__r); }
^
detected during:
instantiation of "_Tp *std::__addressof(_Tp &) [with _Tp=std::__make_not_void<const char16_t>={const char16_t}]" at line 138
instantiation of "_Tp *std::addressof(_Tp &) [with _Tp=std::__make_not_void<const char16_t>={const char16_t}]" at line 142 of "/usr/include/c++/7/bits/ptr_traits.h"
instantiation of "std::pointer_traits<_Tp *>::pointer std::pointer_traits<_Tp *>::pointer_to(std::__make_not_void<std::pointer_traits<_Tp *>::element_type> &) [with _Tp=const char16_t]" at line 176 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_local_data() const [with _CharT=char16_t, _Traits=std::char_traits<char16_t>, _Alloc=std::allocator<char16_t>]" at line 195 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "bool std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_is_local() const [with _CharT=char16_t, _Traits=std::char_traits<char16_t>, _Alloc=std::allocator<char16_t>]" at line 204 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_dispose() [with _CharT=char16_t, _Traits=std::char_traits<char16_t>, _Alloc=std::allocator<char16_t>]" at line 228 of "/usr/include/c++/7/bits/basic_string.tcc"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct(_FwdIterator, _FwdIterator, std::forward_iterator_tag) [with _CharT=char16_t, _Traits=std::char_traits<char16_t>, _Alloc=std::allocator<char16_t>, _FwdIterator=const char16_t *]" at line 220 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct_aux(_InIterator, _InIterator, std::__false_type) [with _CharT=char16_t, _Traits=std::char_traits<char16_t>, _Alloc=std::allocator<char16_t>, _InIterator=const char16_t *]" at line 239 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct(_InIterator, _InIterator) [with _CharT=char16_t, _Traits=std::char_traits<char16_t>, _Alloc=std::allocator<char16_t>, _InIterator=const char16_t *]" at line 486 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT *, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc &) [with _CharT=char16_t, _Traits=std::char_traits<char16_t>, _Alloc=std::allocator<char16_t>]" at line 6486 of "/usr/include/c++/7/bits/basic_string.h"
/usr/include/c++/7/bits/move.h(48): error: identifier "__builtin_addressof" is undefined
{ return __builtin_addressof(__r); }
^
detected during:
instantiation of "_Tp *std::__addressof(_Tp &) [with _Tp=std::__make_not_void<char32_t>={char32_t}]" at line 138
instantiation of "_Tp *std::addressof(_Tp &) [with _Tp=std::__make_not_void<char32_t>={char32_t}]" at line 142 of "/usr/include/c++/7/bits/ptr_traits.h"
instantiation of "std::pointer_traits<_Tp *>::pointer std::pointer_traits<_Tp *>::pointer_to(std::__make_not_void<std::pointer_traits<_Tp *>::element_type> &) [with _Tp=char32_t]" at line 166 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_local_data() [with _CharT=char32_t, _Traits=std::char_traits<char32_t>, _Alloc=std::allocator<char32_t>]" at line 485 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT *, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc &) [with _CharT=char32_t, _Traits=std::char_traits<char32_t>, _Alloc=std::allocator<char32_t>]" at line 6491 of "/usr/include/c++/7/bits/basic_string.h"
/usr/include/c++/7/bits/move.h(48): error: identifier "__builtin_addressof" is undefined
{ return __builtin_addressof(__r); }
^
detected during:
instantiation of "_Tp *std::__addressof(_Tp &) [with _Tp=std::__make_not_void<const char32_t>={const char32_t}]" at line 138
instantiation of "_Tp *std::addressof(_Tp &) [with _Tp=std::__make_not_void<const char32_t>={const char32_t}]" at line 142 of "/usr/include/c++/7/bits/ptr_traits.h"
instantiation of "std::pointer_traits<_Tp *>::pointer std::pointer_traits<_Tp *>::pointer_to(std::__make_not_void<std::pointer_traits<_Tp *>::element_type> &) [with _Tp=const char32_t]" at line 176 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_local_data() const [with _CharT=char32_t, _Traits=std::char_traits<char32_t>, _Alloc=std::allocator<char32_t>]" at line 195 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "bool std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_is_local() const [with _CharT=char32_t, _Traits=std::char_traits<char32_t>, _Alloc=std::allocator<char32_t>]" at line 204 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_dispose() [with _CharT=char32_t, _Traits=std::char_traits<char32_t>, _Alloc=std::allocator<char32_t>]" at line 228 of "/usr/include/c++/7/bits/basic_string.tcc"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct(_FwdIterator, _FwdIterator, std::forward_iterator_tag) [with _CharT=char32_t, _Traits=std::char_traits<char32_t>, _Alloc=std::allocator<char32_t>, _FwdIterator=const char32_t *]" at line 220 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct_aux(_InIterator, _InIterator, std::__false_type) [with _CharT=char32_t, _Traits=std::char_traits<char32_t>, _Alloc=std::allocator<char32_t>, _InIterator=const char32_t *]" at line 239 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_construct(_InIterator, _InIterator) [with _CharT=char32_t, _Traits=std::char_traits<char32_t>, _Alloc=std::allocator<char32_t>, _InIterator=const char32_t *]" at line 486 of "/usr/include/c++/7/bits/basic_string.h"
instantiation of "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT *, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc &) [with _CharT=char32_t, _Traits=std::char_traits<char32_t>, _Alloc=std::allocator<char32_t>]" at line 6491 of "/usr/include/c++/7/bits/basic_string.h"
compilation aborted for test.cpp (code 2)
my icc version is icc version 17.0.0 (gcc version 7.0.0 compatibility),
gcc version is gcc version 7.1.1 20170622 (Red Hat 7.1.1-3) (GCC),
for this error, I feel confused with it. Please help me. Thanks!
Upvotes: 0
Views: 3984
Reputation: 119877
__builtin_addressof
is a relatively new gcc built-in icpc doesn't know how to handle yet. It was added to gcc around October 2016, while icc 17.0 was released in April 2016.
Either downgrade your gcc, or work around the problem by #define
ing __builtin_addressof
as follows:
#define __builtin_addressof(obj) \
(&const_cast<char&>(reinterpret_cast<const volatile char&>(obj)))
when compiling with icpc. You can add the define to the top of your source, or add the corresponding -D
flag to the compiler command line, or (if you are adventurous) patch the system header:
template<typename _Tp>
inline _GLIBCXX_CONSTEXPR _Tp*
__addressof(_Tp& __r) _GLIBCXX_NOEXCEPT
#ifdef __ICC
{ return (&const_cast<char&>(reinterpret_cast<const volatile char&>(__r))); }
#else
{ return __builtin_addressof(__r); }
#endif
This is not C++17 compliant, but at least you should be able to compile something if the stars are right.
Upvotes: 4
Reputation: 11889
Compilers general have their own library code (.h/lib etc) that implement the standard library functionality. These libraries are mostly incompatible with other compilers (e.g. compiler A won't be able to build compiler B's library code).
Of course the code YOU write will be compilable by both compilers.
It looks like the errors you are getting are to do with this problem:
/usr/include/c++/7/bits/move.h(48)
These are the standard gcc library include files. You need to alter your environment/seartch paths, to use the icpc include/lib folders.
__builtin_addressof is an 'intrinsic' that is supported by gcc internally, but is not part of the C++ standard (you can tell by the __ before the function, which usually means 'compiler specific functionality').
Upvotes: 1