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

Compile failure for fmt::sprintf on gcc9.2.0 if using -std:c++17 and above #1354

Closed
hkAlice opened this issue Oct 9, 2019 · 1 comment
Closed

Comments

@hkAlice
Copy link

hkAlice commented Oct 9, 2019

Example code:

#include <string>
#include <fmt/printf.h>

int main( int argc, char *argv[] )
{
    std::string testStr = "fmt::sprintf test: %03d";
    
    uint32_t idx = 1;
    std::string fmtTestStr = fmt::sprintf( testStr, idx );

    return 0;
}
In file included from /run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/format.h:46,
                 from /run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/ostream.h:12,
                 from /run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/printf.h:14,
                 from /run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/src/main.cpp:2:
/run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/core.h: In instantiation of ‘constexpr decltype (vis(0)) fmt::v6::visit_format_arg(Visitor&&, const fmt::v6::basic_format_arg<Context>&) [with Visitor = fmt::v6::printf_arg_formatter<fmt::v6::buffer_range<char> >; Context = fmt::v6::basic_printf_context<std::back_insert_iterator<fmt::v6::internal::buffer<char> >, char>; decltype (vis(0)) = std::back_insert_iterator<fmt::v6::internal::buffer<char> >]’:
/run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/printf.h:562:5:   required from ‘OutputIt fmt::v6::basic_printf_context<OutputIt, Char>::format() [with ArgFormatter = fmt::v6::printf_arg_formatter<fmt::v6::buffer_range<char> >; OutputIt = std::back_insert_iterator<fmt::v6::internal::buffer<char> >; Char = char]’
/run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/printf.h:181:3:   required from ‘void fmt::v6::internal::printf(fmt::v6::internal::buffer<Char>&, fmt::v6::basic_string_view<Char>, fmt::v6::basic_format_args<Context>) [with Char = char; Context = fmt::v6::basic_printf_context<std::back_insert_iterator<fmt::v6::internal::buffer<char> >, char>]’
/run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/printf.h:606:9:   required from ‘std::__cxx11::basic_string<Char> fmt::v6::vsprintf(const S&, fmt::v6::basic_format_args<fmt::v6::basic_printf_context<std::back_insert_iterator<fmt::v6::internal::buffer<Char> >, Char> >) [with S = fmt::v6::basic_string_view<char>; Char = char]’
/run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/printf.h:623:18:   required from ‘std::__cxx11::basic_string<Char> fmt::v6::sprintf(const S&, const Args& ...) [with S = std::__cxx11::basic_string<char>; Args = {unsigned int}; Char = char]’
/run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/src/main.cpp:9:57:   required from here
/run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/core.h:972:15: error: no match for call to ‘(fmt::v6::printf_arg_formatter<fmt::v6::buffer_range<char> >) (const int128_t&)’
  972 |     return vis(arg.value_.int128_value);
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/src/main.cpp:2:
/run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/printf.h:239:12: note: candidate: ‘template<class T, typename std::enable_if<std::is_integral<_Tp>::value, int>::type <anonymous> > fmt::v6::printf_arg_formatter<Range>::iterator fmt::v6::printf_arg_formatter<Range>::operator()(T) [with T = T; typename std::enable_if<std::is_integral<U>::value, int>::type <anonymous> = <enumerator>; Range = fmt::v6::buffer_range<char>]’
  239 |   iterator operator()(T value) {
      |            ^~~~~~~~
/run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/printf.h:239:12: note:   template argument deduction/substitution failed:
In file included from /run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/format.h:46,
                 from /run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/ostream.h:12,
                 from /run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/printf.h:14,
                 from /run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/src/main.cpp:2:
/run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/core.h:218:62: error: no type named ‘type’ in ‘struct std::enable_if<false, int>’
  218 | #define FMT_ENABLE_IF(...) enable_if_t<(__VA_ARGS__), int> = 0
      |                                                              ^
/run/media/maru/Shiki/Data/Dev/fmt-gcc9-test/lib/fmt/include/fmt/printf.h:238:25: note: in expansion of macro ‘FMT_ENABLE_IF’
  238 |   template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>

The snippet fails to compile on gcc9.2.0 when using flags -std=c++17, -std=c++1z-, -std=c++2a etc. It works fine on gcc8 as well as VS2019 MSVC.

Thank you!

@vitaut
Copy link
Contributor

vitaut commented Oct 10, 2019

Should be fixed in 2730e90. Thanks for reporting.

@vitaut vitaut closed this as completed Oct 10, 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