Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation fails with Intel oneAPI 2021.1 #2105

Closed
yafshar opened this issue Jan 19, 2021 · 6 comments
Closed

compilation fails with Intel oneAPI 2021.1 #2105

yafshar opened this issue Jan 19, 2021 · 6 comments

Comments

@yafshar
Copy link
Contributor

yafshar commented Jan 19, 2021

If compiling with the Intel oneAPI 2021.1 Beta 20201112, compilation fails:

with -DCMAKE_CXX_STANDARD=11

cd /test/git/fmt/build/test && icpc -DFMT_LOCALE -I/test/git/fmt/include -O3 -DNDEBUG -std=gnu++11 -o CMakeFiles/fmt.dir/src/format.cc.o -c /test/git/fmt/src/format.cc
In file included from /test/git/fmt/include/fmt/format-inl.h(29),
                 from /test/git/fmt/src/format.cc(8):
/test/git/fmt/include/fmt/format.h(385): warning #1292: unknown attribute "no_sanitize"
  __attribute__((no_sanitize("undefined")))
                 ^

In file included from /test/git/fmt/include/fmt/format-inl.h(29),
                 from /test/git/fmt/src/format.cc(8):
/test/git/fmt/include/fmt/format.h(4049): error: a literal operator template must have a template parameter list equivalent to "<char ...>"
  FMT_CONSTEXPR detail::udl_formatter<Char, CHARS...> operator""_format() {
                                                      ^

compilation aborted for /test/git/fmt/src/format.cc (code 2)

A similar issue #742 has been reported and resolved before (with a fix fba352a)

with -DCMAKE_CXX_STANDARD=14

cd /test/git/fmt/build/test && icpc -DFMT_ENFORCE_COMPILE_STRING -DFMT_LOCALE -DGTEST_HAS_STD_WSTRING=1 -DGTEST_LANG_CXX11=0 -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 -I/test/git/fmt/include -I/test/git/fmt/test/gtest -I/test/git/fmt/test/gmock -I/test/git/fmt/test/. -O3 -DNDEBUG -fno-delete-null-pointer-checks -std=gnu++14 -o CMakeFiles/enforce-compile-string-test.dir/enforce-compile-string-test.cc.o -c /test/git/fmt/test/enforce-compile-string-test.cc
In file included from /test/git/fmt/include/fmt/chrono.h(17),
                 from /test/git/fmt/test/enforce-compile-string-test.cc(14):
/test/git/fmt/include/fmt/format.h(385): warning #1292: unknown attribute "no_sanitize"
  __attribute__((no_sanitize("undefined")))
                 ^

/test/git/fmt/include/fmt/format.h(4018): error: no suitable user-defined conversion from "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>" to "std::__1::basic_string<const char, std::__1::char_traits<const char>, std::__1::allocator<const char>>" exists
      return format(FMT_STRING(s), std::forward<Args>(args)...);
             ^
          detected during instantiation of "std::__1::basic_string<Char, std::__1::char_traits<Char>, std::__1::allocator<Char>> fmt::v7::detail::udl_formatter<Char, CHARS...>::operator()(Args &&...) const [with Char=const char, CHARS=<'{', '}', 'c', '{', '}'>, Args=<const char (&)[3], int>]" at line 43 of "/test/git/fmt/test/enforce-compile-string-test.cc"

/test/git/fmt/include/fmt/format.h(4018): error: no suitable user-defined conversion from "std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t>>" to "std::__1::basic_string<const wchar_t, std::__1::char_traits<const wchar_t>, std::__1::allocator<const wchar_t>>" exists
      return format(FMT_STRING(s), std::forward<Args>(args)...);
             ^
          detected during instantiation of "std::__1::basic_string<Char, std::__1::char_traits<Char>, std::__1::allocator<Char>> fmt::v7::detail::udl_formatter<Char, CHARS...>::operator()(Args &&...) const [with Char=const wchar_t, CHARS=<123, 125, 99, 123, 125>, Args=<const wchar_t (&)[3], int>]" at line 44 of "/test/git/fmt/test/enforce-compile-string-test.cc"

compilation aborted for /test/git/fmt/test/enforce-compile-string-test.cc (code 2)

with -DCMAKE_CXX_STANDARD=17

cd /test/git/fmt/build/test && icpc -DFMT_ENFORCE_COMPILE_STRING -DFMT_LOCALE -DGTEST_HAS_STD_WSTRING=1 -DGTEST_LANG_CXX11=0 -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 -I/test/git/fmt/include -I/test/git/fmt/test/gtest -I/test/git/fmt/test/gmock -I/test/git/fmt/test/. -O3 -DNDEBUG -fno-delete-null-pointer-checks -std=gnu++17 -o CMakeFiles/enforce-compile-string-test.dir/enforce-compile-string-test.cc.o -c /test/git/fmt/test/enforce-compile-string-test.cc
In file included from /test/git/fmt/include/fmt/chrono.h(17),
                 from /test/git/fmt/test/enforce-compile-string-test.cc(14):
/test/git/fmt/include/fmt/format.h(385): warning #1292: unknown attribute "no_sanitize"
  __attribute__((no_sanitize("undefined")))
                 ^

/test/git/fmt/include/fmt/format.h(4018): error: no suitable user-defined conversion from "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>" to "std::__1::basic_string<const char, std::__1::char_traits<const char>, std::__1::allocator<const char>>" exists
      return format(FMT_STRING(s), std::forward<Args>(args)...);
             ^
          detected during instantiation of "std::__1::basic_string<Char, std::__1::char_traits<Char>, std::__1::allocator<Char>> fmt::v7::detail::udl_formatter<Char, CHARS...>::operator()(Args &&...) const [with Char=const char, CHARS=<'{', '}', 'c', '{', '}'>, Args=<const char (&)[3], int>]" at line 43 of "/test/git/fmt/test/enforce-compile-string-test.cc"

/test/git/fmt/include/fmt/format.h(4018): error: no suitable user-defined conversion from "std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t>>" to "std::__1::basic_string<const wchar_t, std::__1::char_traits<const wchar_t>, std::__1::allocator<const wchar_t>>" exists
      return format(FMT_STRING(s), std::forward<Args>(args)...);
             ^
          detected during instantiation of "std::__1::basic_string<Char, std::__1::char_traits<Char>, std::__1::allocator<Char>> fmt::v7::detail::udl_formatter<Char, CHARS...>::operator()(Args &&...) const [with Char=const wchar_t, CHARS=<123, 125, 99, 123, 125>, Args=<const wchar_t (&)[3], int>]" at line 44 of "/test/git/fmt/test/enforce-compile-string-test.cc"

compilation aborted for /test/git/fmt/test/enforce-compile-string-test.cc (code 2)

with -DCMAKE_CXX_STANDARD=20

cd /test/git/fmt/build/test && icpc -DFMT_ENFORCE_COMPILE_STRING -DFMT_LOCALE -DGTEST_HAS_STD_WSTRING=1 -DGTEST_LANG_CXX11=0 -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 -I/test/git/fmt/include -I/test/git/fmt/test/gtest -I/test/git/fmt/test/gmock -I/test/git/fmt/test/. -O3 -DNDEBUG -fno-delete-null-pointer-checks -std=gnu++20 -o CMakeFiles/enforce-compile-string-test.dir/enforce-compile-string-test.cc.o -c /test/git/fmt/test/enforce-compile-string-test.cc
In file included from /test/git/fmt/include/fmt/chrono.h(17),
                 from /test/git/fmt/test/enforce-compile-string-test.cc(14):
/test/git/fmt/include/fmt/format.h(385): warning #1292: unknown attribute "no_sanitize"
  __attribute__((no_sanitize("undefined")))
                 ^

/test/git/fmt/include/fmt/format.h(4018): error: no suitable user-defined conversion from "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>" to "std::__1::basic_string<const char, std::__1::char_traits<const char>, std::__1::allocator<const char>>" exists
      return format(FMT_STRING(s), std::forward<Args>(args)...);
             ^
          detected during instantiation of "std::__1::basic_string<Char, std::__1::char_traits<Char>, std::__1::allocator<Char>> fmt::v7::detail::udl_formatter<Char, CHARS...>::operator()(Args &&...) const [with Char=const char, CHARS=<'{', '}', 'c', '{', '}'>, Args=<const char (&)[3], int>]" at line 43 of "/test/git/fmt/test/enforce-compile-string-test.cc"

/test/git/fmt/include/fmt/format.h(4018): error: no suitable user-defined conversion from "std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t>>" to "std::__1::basic_string<const wchar_t, std::__1::char_traits<const wchar_t>, std::__1::allocator<const wchar_t>>" exists
      return format(FMT_STRING(s), std::forward<Args>(args)...);
             ^
          detected during instantiation of "std::__1::basic_string<Char, std::__1::char_traits<Char>, std::__1::allocator<Char>> fmt::v7::detail::udl_formatter<Char, CHARS...>::operator()(Args &&...) const [with Char=const wchar_t, CHARS=<123, 125, 99, 123, 125>, Args=<const wchar_t (&)[3], int>]" at line 44 of "/test/git/fmt/test/enforce-compile-string-test.cc"

compilation aborted for /test/git/fmt/test/enforce-compile-string-test.cc (code 2)

Host info:

>> sw_vers   
ProductName:	macOS
ProductVersion:	11.1
BuildVersion:	20C69

Compiler info:

>> icpc --version
icpc (ICC) 2021.1 Beta 20201112
Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.
@vitaut
Copy link
Contributor

vitaut commented Jan 19, 2021

Could you submit a PR to exclude this compiler in

fmt/include/fmt/format.h

Lines 154 to 158 in 7fd535c

# if FMT_USE_USER_DEFINED_LITERALS && \
(!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 501) && \
((FMT_GCC_VERSION >= 604 && __cplusplus >= 201402L) || \
FMT_CLANG_VERSION >= 304) && \
!defined(__PGI) && !defined(__NVCC__)
since you are in the best position to check it the workaround works?

@yafshar
Copy link
Contributor Author

yafshar commented Jan 19, 2021

I tried to exclude the compiler simply by doing:

#ifndef FMT_USE_UDL_TEMPLATE
// EDG frontend based compilers (icc, nvcc, PGI, etc) and GCC < 6.4 do not
// properly support UDL templates and GCC >= 9 warns about them.
#  if FMT_USE_USER_DEFINED_LITERALS &&                         \
      (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 501) && \
      ((FMT_GCC_VERSION >= 604 && __cplusplus >= 201402L) ||   \
       FMT_CLANG_VERSION >= 304) && !(FMT_ICC_VERSION == 2021) && \
      !defined(__PGI) && !defined(__NVCC__)
#    define FMT_USE_UDL_TEMPLATE 1
#  else
#    define FMT_USE_UDL_TEMPLATE 0
#  endif
#endif

but this does not resolve the issue, another error happened at another place:
with -DCMAKE_CXX_STANDARD=11

/test/git/fmt/include/fmt/format.h(3849): error: no instance of overloaded function "fmt::v7::detail::write" matches the argument list
            argument types are: (std::__1::back_insert_iterator<std::__1::string>, const fmt_test::ABC)
    detail::write<char>(std::back_inserter(result), value);
    ^
/test/git/fmt/include/fmt/format.h(2167): note: this candidate was rejected because there is a type mismatch after argument substitution
  auto write(OutputIt out, const T& value) -> typename std::enable_if<
       ^
/test/git/fmt/include/fmt/format.h(2162): note: this candidate was rejected because arguments do not match
  OutputIt write(OutputIt out, const void* value) {
           ^
/test/git/fmt/include/fmt/format.h(2151): note: this candidate was rejected because arguments do not match
  FMT_CONSTEXPR OutputIt write(OutputIt out, const Char* value) {
                         ^
/test/git/fmt/include/fmt/format.h(2144): note: this candidate was rejected because arguments do not match
  FMT_CONSTEXPR OutputIt write(OutputIt out, Char value) {
                         ^
/test/git/fmt/include/fmt/format.h(2139): note: this candidate was rejected because arguments do not match
  constexpr OutputIt write(OutputIt out, bool value) {
                     ^
/test/git/fmt/include/fmt/format.h(2133): note: this candidate was rejected because at least one template argument could not be deduced
  FMT_CONSTEXPR OutputIt write(OutputIt out, T value) {
                         ^
/test/git/fmt/include/fmt/format.h(2107): note: this candidate was rejected because at least one template argument could not be deduced
  FMT_CONSTEXPR OutputIt write(OutputIt out, T value) {
                         ^
/test/git/fmt/include/fmt/format.h(2097): note: this candidate was rejected because arguments do not match
  FMT_CONSTEXPR OutputIt write(OutputIt out, basic_string_view<Char> value) {
                         ^
/test/git/fmt/include/fmt/format.h(2090): note: this candidate was rejected because arguments do not match
  OutputIt write(OutputIt out, string_view value) {
           ^
/test/git/fmt/include/fmt/format.h(2083): note: this candidate was rejected because arguments do not match
  OutputIt write(OutputIt out, monostate) {
           ^
/test/git/fmt/include/fmt/format.h(2059): note: this candidate was rejected because at least one template argument could not be deduced
  inline OutputIt write(OutputIt out, T value) {
                  ^
/test/git/fmt/include/fmt/format.h(2033): note: this candidate was rejected because at least one template argument could not be deduced
  OutputIt write(OutputIt out, T value) {
           ^
/test/git/fmt/include/fmt/format.h(1985): note: this candidate was rejected because at least one template argument could not be deduced
  OutputIt write(OutputIt out, T value, basic_format_specs<Char> specs,
           ^
/test/git/fmt/include/fmt/format.h(1646): note: this candidate was rejected because at least one template argument could not be deduced
  FMT_CONSTEXPR OutputIt write(OutputIt out, basic_string_view<StrChar> s,
                         ^
          detected during instantiation of "std::__1::string fmt::v7::to_string(const T &) [with T=fmt_test::ABC, <unnamed>=0]" at line 330 of "//test/git/fmt/test/ostream-test.cc"

@yafshar
Copy link
Contributor Author

yafshar commented Jan 19, 2021

There might be an incompatibility or issue with this Intel compiler on macOS. I would try this on Linux to make sure.

@yafshar
Copy link
Contributor Author

yafshar commented Jan 22, 2021

The same error is happening on

  • Linux Ubuntu 18.04
  •  >> icpc --version
     icpc (ICC) 2021.1 Beta 20201112
     Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.
>> cmake .. -DCMAKE_CXX_COMPILER=icpc -DCMAKE_CXX_STANDARD=11
>> make
/root/fmt/include/fmt/format.h(3849): error: no instance of overloaded function "fmt::v7::detail::write" matches the argument list
            argument types are: (std::back_insert_iterator<std::__cxx11::string>, const adl_test::fmt::detail::foo)
    detail::write<char>(std::back_inserter(result), value);
    ^
/root/fmt/include/fmt/format.h(2167): note: this candidate was rejected because there is a type mismatch after argument substitution
  auto write(OutputIt out, const T& value) -> typename std::enable_if<
       ^
/root/fmt/include/fmt/format.h(2162): note: this candidate was rejected because arguments do not match
  OutputIt write(OutputIt out, const void* value) {
           ^
/root/fmt/include/fmt/format.h(2151): note: this candidate was rejected because arguments do not match
  FMT_CONSTEXPR OutputIt write(OutputIt out, const Char* value) {
                         ^
/root/fmt/include/fmt/format.h(2144): note: this candidate was rejected because arguments do not match
  FMT_CONSTEXPR OutputIt write(OutputIt out, Char value) {
                         ^
/root/fmt/include/fmt/format.h(2139): note: this candidate was rejected because arguments do not match
  constexpr OutputIt write(OutputIt out, bool value) {
                     ^
/root/fmt/include/fmt/format.h(2133): note: this candidate was rejected because at least one template argument could not be deduced
  FMT_CONSTEXPR OutputIt write(OutputIt out, T value) {
                         ^
/root/fmt/include/fmt/format.h(2107): note: this candidate was rejected because at least one template argument could not be deduced
  FMT_CONSTEXPR OutputIt write(OutputIt out, T value) {
                         ^
/root/fmt/include/fmt/format.h(2097): note: this candidate was rejected because arguments do not match
  FMT_CONSTEXPR OutputIt write(OutputIt out, basic_string_view<Char> value) {
                         ^
/root/fmt/include/fmt/format.h(2090): note: this candidate was rejected because arguments do not match
  OutputIt write(OutputIt out, string_view value) {
           ^
/root/fmt/include/fmt/format.h(2083): note: this candidate was rejected because arguments do not match
  OutputIt write(OutputIt out, monostate) {
           ^
/root/fmt/include/fmt/format.h(2059): note: this candidate was rejected because at least one template argument could not be deduced
  inline OutputIt write(OutputIt out, T value) {
                  ^
/root/fmt/include/fmt/format.h(2033): note: this candidate was rejected because at least one template argument could not be deduced
  OutputIt write(OutputIt out, T value) {
           ^
/root/fmt/include/fmt/format.h(1985): note: this candidate was rejected because mismatch in count of arguments
  OutputIt write(OutputIt out, T value, basic_format_specs<Char> specs,
           ^
/root/fmt/include/fmt/format.h(1646): note: this candidate was rejected because mismatch in count of arguments
  FMT_CONSTEXPR OutputIt write(OutputIt out, basic_string_view<StrChar> s,
                         ^
          detected during instantiation of "std::__cxx11::string fmt::v7::to_string(const T &) [with T=adl_test::fmt::detail::foo, <unnamed>=0]" at line 1994 of "/root/fmt/test/format-test.cc"

@yafshar yafshar changed the title compilation fails with Intel oneAPI 2021.1 on macOS compilation fails with Intel oneAPI 2021.1 Jan 22, 2021
@vitaut
Copy link
Contributor

vitaut commented Jan 30, 2021

Looks like a bug in icpc. It should have matched this overload:

/root/fmt/include/fmt/format.h(2167): note: this candidate was rejected because there is a type mismatch after argument substitution
  auto write(OutputIt out, const T& value) -> typename std::enable_if<
       ^

which is

fmt/include/fmt/format.h

Lines 2190 to 2194 in 2a25e2b

template <typename Char, typename OutputIt, typename T>
auto write(OutputIt out, const T& value) -> typename std::enable_if<
mapped_type_constant<T, basic_format_context<OutputIt, Char>>::value ==
type::custom_type,
OutputIt>::type {

A PR with a workaround will be welcome if you manage to find one (e.g. disable ostream tests). In the meantime you might be able to use {fmt} without ostream support which is not essential anyway.

@vitaut
Copy link
Contributor

vitaut commented Mar 27, 2021

The UDL issue should be fixed in 417e1ce. As for the overload resolution issue, it looks like a bug in icpc, I recommend reporting there.

@vitaut vitaut closed this as completed Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants