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

Conflict in fmt/ostream.h #830

Closed
chronoxor opened this issue Aug 10, 2018 · 2 comments
Closed

Conflict in fmt/ostream.h #830

chronoxor opened this issue Aug 10, 2018 · 2 comments

Comments

@chronoxor
Copy link
Contributor

The following example does not compile under gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)

#include <fmt/format.h>
#include <fmt/ostream.h> // Adding this include failed with compile error!

using namespace fmt::literals;

int main(int argc, char** argv)
{
    std::cout << "{}"_format("test");
    return 0;
}

Produced error:

/home/user/CppCommon/modules/fmt/include/fmt/format.h: In instantiation of ‘constexpr const typename ParseContext::char_type* fmt::v5::internal::parse_format_specs(ParseContext&) [with T = char [5]; ParseContext = fmt::v5::basic_parse_context<char>; typename ParseContext::char_type = char]’:
/home/user/CppCommon/modules/fmt/include/fmt/format.h:2256:68:   required from ‘constexpr fmt::v5::internal::format_string_checker<Char, ErrorHandler, Args>::format_string_checker(fmt::v5::basic_string_view<Char>, ErrorHandler) [with Char = char; ErrorHandler = fmt::v5::internal::error_handler; Args = {char [5]}]’
/home/user/CppCommon/modules/fmt/include/fmt/format.h:2305:54:   required from ‘constexpr bool fmt::v5::internal::check_format_string(fmt::v5::basic_string_view<Char>, ErrorHandler) [with Char = char; ErrorHandler = fmt::v5::internal::error_handler; Args = {char [5]}]’
/home/user/CppCommon/modules/fmt/include/fmt/format.h:3850:58:   required from ‘std::__cxx11::basic_string<_CharT> fmt::v5::internal::udl_formatter<Char, CHARS>::operator()(const Args& ...) const [with Args = {char [5]}; Char = char; Char ...CHARS = {'{', '}'}]’
/home/user/CppCommon/examples/string_format.cpp:8:36:   required from here
/home/user/CppCommon/modules/fmt/include/fmt/format.h:2246:50: error: ambiguous template instantiation for ‘struct fmt::v5::formatter<char [5], char, void>’
   formatter<T, typename ParseContext::char_type> f{};
                                                  ^
/home/user/CppCommon/modules/fmt/include/fmt/format.h:3183:8: note: candidates are: template<class T, class Char> struct fmt::v5::formatter<T, Char, typename std::enable_if<fmt::v5::internal::format_type<typename fmt::v5::buffer_context<Char>::type, T>::value>::type> [with T = char [5]; Char = char]
 struct formatter<
        ^~~~~~~~~~
     T, Char,
     ~~~~~~~~
     typename std::enable_if<internal::format_type<
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         typename buffer_context<Char>::type, T>::value>::type> {
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/user/CppCommon/examples/string_format.cpp:2:0:
/home/user/CppCommon/modules/fmt/include/fmt/ostream.h:113:8: note:                 template<class T, class Char> struct fmt::v5::formatter<T, Char, typename std::enable_if<fmt::v5::internal::is_streamable<T, Char>::value>::type> [with T = char [5]; Char = char]
 struct formatter<T, Char,
        ^~~~~~~~~~~~~~~~~~
     typename std::enable_if<internal::is_streamable<T, Char>::value>::type>
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/user/CppCommon/examples/string_format.cpp:1:0:
/home/user/CppCommon/modules/fmt/include/fmt/format.h:2246:50: error: ‘fmt::v5::formatter<char [5], char, void> f’ has incomplete type
   formatter<T, typename ParseContext::char_type> f{};
                                                  ^

@chronoxor
Copy link
Contributor Author

Also there is a small warning/error in Clang in pedantic compile mode:

/Users/travis/build/chronoxor/CppCommon/modules/fmt/include/fmt/format.h:3885:55: error: string literal operator templates are a GNU extension [-Werror,-Wgnu-string-literal-operator-template]
FMT_CONSTEXPR internal::udl_formatter<Char, CHARS...> operator""_format() {
                                                      ^
In file included from /Users/travis/build/chronoxor/CppCommon/modules/fmt/src/posix.cc:13:
In file included from /Users/travis/build/chronoxor/CppCommon/modules/fmt/include/fmt/posix.h:28:
/Users/travis/build/chronoxor/CppCommon/modules/fmt/include/fmt/format.h:3885:55: error: string literal operator templates are a GNU extension [-Werror,-Wgnu-string-literal-operator-template]
FMT_CONSTEXPR internal::udl_formatter<Char, CHARS...> operator""_format() {
                                                      ^

@vitaut
Copy link
Contributor

vitaut commented Aug 11, 2018

Fixed in 8b9fb9f, thanks for reporting! The warning should already be suppressed in https://github.com/fmtlib/fmt/blob/master/CMakeLists.txt#L101, but a PR is welcome if there is some case where it still occurs.

@vitaut vitaut closed this as completed Aug 11, 2018
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