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

error: call to non-‘constexpr’ function ‘void fmt::v8::detail::error_handler::on_error(const char*)’ #2023

Closed
boxerab opened this issue Jul 29, 2021 · 10 comments

Comments

@boxerab
Copy link

boxerab commented Jul 29, 2021

I just updated my project to the latest master version of spdlog.

Now, these lines trigger a compiler error:
(g++ 10.3 )

char* s = "cat";
char sep = ',';
spdlog::error("Could not parse precinct dimension: {} {0:x}", s, sep);
/home/src/grok/src/bin/jp2/grk_compress.cpp:963:74:   in ‘constexpr’ expansion of ‘fmt::v8::basic_format_string<char, char*&, char&>("Could not parse precinct dimension: {} {0:x}")’
/home/src/grok/src/include/spdlog/fmt/bundled/core.h:2845:40:   in ‘constexpr’ expansion of ‘fmt::v8::detail::parse_format_string<true, char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, char*, char> >(((fmt::v8::basic_format_string<char, char*&, char&>*)this)->fmt::v8::basic_format_string<char, char*&, char&>::str_, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, char*, char>(fmt::v8::basic_string_view<char>(((const char*)s)), (fmt::v8::detail::error_handler(), fmt::v8::detail::error_handler())))’
/home/src/grok/src/include/spdlog/fmt/bundled/core.h:2430:36:   in ‘constexpr’ expansion of ‘fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, char*, char>&>(p, end, (* & handler))’
/home/src/grok/src/include/spdlog/fmt/bundled/core.h:2366:25:   in ‘constexpr’ expansion of ‘fmt::v8::detail::parse_arg_id<char, fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, char*, char>&>::id_adapter&>(begin, end, adapter)’
/home/src/grok/src/include/spdlog/fmt/bundled/core.h:2197:51:   in ‘constexpr’ expansion of ‘fmt::v8::detail::do_parse_arg_id<char, fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, char*, char>&>::id_adapter&>(begin, end, (* & handler))’
/home/src/grok/src/include/spdlog/fmt/bundled/core.h:2178:14:   in ‘constexpr’ expansion of ‘(& handler)->fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, char*, char>&>::id_adapter::operator()(index)’
/home/src/grok/src/include/spdlog/fmt/bundled/core.h:2349:71:   in ‘constexpr’ expansion of ‘(&((fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, char*, char>&>::id_adapter*)this)->fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, char*, char>&>::id_adapter::handler)->fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, char*, char>::on_arg_id(id)’
/home/src/grok/src/include/spdlog/fmt/bundled/core.h:2694:33:   in ‘constexpr’ expansion of ‘((fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, char*, char>*)this)->fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, char*, char>::context_.fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler>::check_arg_id(id)’
/home/src/grok/src/include/spdlog/fmt/bundled/core.h:2472:23:   in ‘constexpr’ expansion of ‘((fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler>*)this)->fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler>::<anonymous>.fmt::v8::basic_format_parse_context<char>::check_arg_id(id)’
/home/src/grok/src/include/spdlog/fmt/bundled/core.h:672:15: error: ‘constexpr void fmt::v8::basic_format_parse_context<Char, ErrorHandler>::on_error(const char*) [with Char = char; ErrorHandler = fmt::v8::detail::error_handler]’ called in a constant expression
  672 |       on_error("cannot switch from automatic to manual argument indexing");
      |       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/src/grok/src/include/spdlog/fmt/bundled/core.h:679:22: note: ‘constexpr void fmt::v8::basic_format_parse_context<Char, ErrorHandler>::on_error(const char*) [with Char = char; ErrorHandler = fmt::v8::detail::error_handler]’ is not usable as a ‘constexpr’ function because:
  679 |   FMT_CONSTEXPR void on_error(const char* message) {
      |                      ^~~~~~~~
/home/src/grok/src/include/spdlog/fmt/bundled/core.h:680:27: error: call to non-‘constexpr’ function ‘void fmt::v8::detail::error_handler::on_error(const char*)’
  680 |     ErrorHandler::on_error(message);
@gabime
Copy link
Owner

gabime commented Jul 29, 2021

Seems like gcc 10 specific issue (are you compiling with c++ 20?)

@boxerab
Copy link
Author

boxerab commented Jul 29, 2021

Yes, c++20

@gabime
Copy link
Owner

gabime commented Jul 29, 2021

You could try different version of gcc or turn off c++20 if you must use this particular gcc version..

@boxerab
Copy link
Author

boxerab commented Jul 29, 2021

I'm afraid I need c++20 for other parts of the code.

@Jackson-soft
Copy link

same issue, C++20

Apple clang version 12.0.5 (clang-1205.0.22.9)

@dkavolis
Copy link
Contributor

dkavolis commented Aug 9, 2021

/home/src/grok/src/include/spdlog/fmt/bundled/core.h:672:15: error: ‘constexpr void fmt::v8::basic_format_parse_context<Char, ErrorHandler>::on_error(const char*) [with Char = char; ErrorHandler = fmt::v8::detail::error_handler]’ called in a constant expression
  672 |       on_error("cannot switch from automatic to manual argument indexing");
      |       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

fmt gives an explanation on what is wrong with the format string, it is not an issue with the library. The error is caught at compile time instead of runtime.

@gabime
Copy link
Owner

gabime commented Aug 9, 2021

@boxerab What is the format string that causing this? could be like @dkavolis said a bad format string.

@dkavolis
Copy link
Contributor

dkavolis commented Aug 9, 2021

@boxerab What is the format string that causing this? could be like @dkavolis said a bad format string.

"Could not parse precinct dimension: {} {0:x}" is mixing automatic and manual indexing, fmt does not allow this as indicated by the error.

@gabime
Copy link
Owner

gabime commented Aug 9, 2021

@boxerab does fixing the format string solves it?

@boxerab
Copy link
Author

boxerab commented Aug 9, 2021

@gabime yep, that fixed it. I will close this now - @Jackson-soft, please can you please open a new issue if this is still a problem for you ?

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

4 participants