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

Specialization of fmt::formatter followed by inclusion of <ostream.h> rejected by gcc #1118

Closed
lubgr opened this issue Apr 17, 2019 · 2 comments

Comments

@lubgr
Copy link

lubgr commented Apr 17, 2019

The following snippet fails to compile with any recent gcc version.

#include <type_traits>
#include <fmt/format.h>

struct Test {};

namespace fmt {
   template<>
      struct formatter<Test> : formatter<int> {
         template <typename FormatContext>
            auto format(const Test&, FormatContext &ctx) {
               return formatter<int>::format(42, ctx);
            }
      };
}

// When moved on top of the specialization, it works fine:
#include <fmt/ostream.h>

The error message is

fmt/ostream.h:115:45: error: partial specialization of 'struct fmt::v5::convert_to_int<T, Char, void>' after instantiation of 'struct fmt::v5::convert_to_int<int, char, void>' [-fpermissive]
template <typename T, typename Char> struct convert_to_int<T, Char, void> {

Contrary, clang happily compiles this. See godbolt.

Thanks in advance for having a look! I could also try to fix it, but not today at least :)

@vitaut
Copy link
Contributor

vitaut commented Apr 20, 2019

Fixed in 5efb24d, thanks for reporting!

@vitaut vitaut closed this as completed Apr 20, 2019
@lubgr
Copy link
Author

lubgr commented Apr 23, 2019

Awesome, thanks for fixing it immediately!

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