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

fmt v6.0.0 has a compiler error under Intel Compiler v19.0 #1273

Closed
sharpe5 opened this issue Aug 26, 2019 · 9 comments
Closed

fmt v6.0.0 has a compiler error under Intel Compiler v19.0 #1273

sharpe5 opened this issue Aug 26, 2019 · 9 comments

Comments

@sharpe5
Copy link

sharpe5 commented Aug 26, 2019

Firstly, thank you for your fantastic work on this library. It really is soooo much nicer than chevron hell, especially when doing something simple like changing number of significant figures for a double.

So everything is working under Visual Studio 2017 v15.9. However, when I switch to Intel Compiler v19.0, it generates compiler errors.

Compiler errors:

3>[snip]\include\fmt\core.h(477): error : attribute does not apply to any entity
3>  using parse_context FMT_DEPRECATED = basic_parse_context<char>;
3>                      ^
3>
3>[snip]\fmt\include\fmt\core.h(478): error : attribute does not apply to any entity
3>  using wparse_context FMT_DEPRECATED = basic_parse_context<wchar_t>;
3>                       ^
3>
3>[snip]\fmt\include\fmt\format.h(2599): error : attribute does not apply to any entity
3>  using writer FMT_DEPRECATED = internal::writer;
3>               ^
3>
3>[snip]\fmt\include\fmt\format.h(2600): error : attribute does not apply to any entity
3>  using wwriter FMT_DEPRECATED =
3>                ^
3>
3>compilation aborted for main.cpp (code 2)
3>Done building project "main.vcxproj" -- FAILED.
9>------ Build started: Project: Project, Configuration: Debug x64 ------
9>  Project -> load.exe
========== Build: 8 succeeded, 1 failed, 46 up-to-date, 0 skipped ==========
@sharpe5 sharpe5 changed the title Fails to compile under Intel Compiler v19.0 fmt v6.0.0 has a compiler error Intel Compiler v19.0 Aug 26, 2019
@sharpe5 sharpe5 changed the title fmt v6.0.0 has a compiler error Intel Compiler v19.0 fmt v6.0.0 has a compiler error under Intel Compiler v19.0 Aug 26, 2019
@sharpe5
Copy link
Author

sharpe5 commented Aug 26, 2019

Found a workaround.

Everything is compiling nicely now.

The fix is to compile in header-only mode (i.e. do not include format.cc and posix.cc within Visual Studio), and also #define FMT_DEPRECATED:

#define FMT_HEADER_ONLY
#define FMT_DEPRECATED // Necessary in v6.0.0 of fmt library to avoid a Intel C++ v19.0 compiler error.
// Add path to include files, e.g. "fmt/include", to project properties under "VC++ Directories" and "Include Directories".
#include <fmt/core.h>
#include <fmt/format.h>

int main()
{
  std::cout << "Hello World!\n";
  fmt::print("Hello, {}!", "world");
}

@vitaut
Copy link
Contributor

vitaut commented Aug 27, 2019

Intel compiler should be disabled here:

# if (FMT_HAS_CPP_ATTRIBUTE(deprecated) && __cplusplus >= 201402L) || \

or here:

# if defined(__GNUC__) || defined(__clang__)

Could you by any chance submit a PR since you in the best position to test it?

@sharpe5
Copy link
Author

sharpe5 commented Aug 27, 2019 via email

@sharpe5
Copy link
Author

sharpe5 commented Aug 27, 2019

Closed the pull request.

The problem is that the Intel Compiler generally accepts the [[deprecated]] attribute, but it does not on the following lines of code:

using parse_context FMT_DEPRECATED = basic_parse_context<char>;

using wparse_context FMT_DEPRECATED = basic_parse_context<wchar_t>;

using writer FMT_DEPRECATED = internal::writer;

using wwriter FMT_DEPRECATED =internal::basic_writer<internal::buffer_range<wchar_t>>;

What make it weirder is that it will accept an invalid token such as [[deprecatedZZZZ]] or [[gnu:deprecatedZZZZZ]] on those lines, but it will not accept a valid token such as [[deprecated]]. This looks and feels like a bug in the compiler to me.

The [[deprecated]] token works perfectly well on these lines of code:

struct FMT_DEPRECATED convert_to_int
    : bool_constant<!std::is_arithmetic<T>::value &&
                    std::is_convertible<T, int>::value> {};

FMT_DEPRECATED static constexpr unsigned long long TYPES = types;

FMT_DEPRECATED format_specs* spec() { return specs_; }

template <typename Range>
using basic_writer FMT_DEPRECATED = internal::basic_writer<Range>;

Given this odd behavior, here are two possible solutions:

I think it's probably more important that it compiles without any issues, so my vote is with #1.

Option #2 is possible, but it would make the code more complicated?

@vitaut
Copy link
Contributor

vitaut commented Aug 28, 2019

Option 2 is not very complicated and more localized, so I'd go with that. Does 744302a fix the problem?

@sharpe5
Copy link
Author

sharpe5 commented Aug 28, 2019 via email

@sharpe5
Copy link
Author

sharpe5 commented Aug 28, 2019

Works perfectly! Issue closed.

I've also made the authors of the Intel Compiler v19.0 aware of this problem, so hopefully it will disappear in the future, and we can only have this workaround enabled for pre-v19.01 versions of the compiler.

@sharpe5 sharpe5 closed this as completed Aug 28, 2019
@vitaut
Copy link
Contributor

vitaut commented Aug 28, 2019

Great, thanks for reporting the issue and verifying the workaround.

@sharpe5
Copy link
Author

sharpe5 commented Aug 29, 2019 via email

kc9jud pushed a commit to nd-nuclear-theory/fmt that referenced this issue Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants