Compile error caused by a missing argument in a print statement
tom-kuca opened this issue · 3 comments
tom-kuca commented
I tried to build the project on ArchLinux with g++ (GCC) 11.1.0 using cmake .
and make
. I got following error:
In file included from /home/tomas/code/nvui/src/nvim.cpp:15:
/usr/include/fmt/core.h: In member function ‘void Nvim::send_response(uint64_t, msgpack::v2::object, msgpack::v2::object)’:
/home/tomas/code/nvui/src/nvim.cpp:486:15: in ‘constexpr’ expansion of ‘fmt::v8::basic_format_string<char>("Could not send response. Msgid: {}\012")’
/usr/include/fmt/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> >(((fmt::v8::basic_format_string<char>*)this)->fmt::v8::basic_format_string<char>::str_, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler>(fmt::v8::basic_string_view<char>(((const char*)s)), (fmt::v8::detail::error_handler(), fmt::v8::detail::error_handler())))’
/usr/include/fmt/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>&>(p, end, (* & handler))’
/usr/include/fmt/core.h:2361:51: in ‘constexpr’ expansion of ‘(& handler)->fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler>::on_arg_id()’
/usr/include/fmt/core.h:2692:70: in ‘constexpr’ expansion of ‘((fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler>*)this)->fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler>::context_.fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler>::next_arg_id()’
/usr/include/fmt/core.h:2467:40: 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
2467 | if (id >= num_args_) this->on_error("argument not found");
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/fmt/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) {
| ^~~~~~~~
/usr/include/fmt/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);
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/fmt/format.h:2825,
from /usr/include/fmt/core.h:3000,
from /home/tomas/code/nvui/src/nvim.cpp:15:
/usr/include/fmt/format-inl.h:2552:15: note: ‘void fmt::v8::detail::error_handler::on_error(const char*)’ declared here
2552 | FMT_FUNC void detail::error_handler::on_error(const char* message) {
| ^~~~~~
make[2]: *** [CMakeFiles/nvui_test.dir/build.make:174: CMakeFiles/nvui_test.dir/src/nvim.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:323: CMakeFiles/nvui_test.dir/all] Error 2
make: *** [Makefile:101: all] Error 2
It looks like there is a reference in the format string without any variable passed:
Line 486 in a48267d
I tried removing {}
from the format string, the compilation finished without it.
rohit-px2 commented
Yeah, crazy how that didn't cause a compile error on anything I've tried so far. It should be printing the message id.
Thanks for reporting this, I'll add a commit to fix it.
tom-kuca commented
It does, thanks!