Skip to content

compilation error, is not usable as a ‘constexpr’ function #414

@nihui

Description

@nihui

fedora 35
gcc 11.2.1, c++20 enabled
spdlog 1.9.2

[ 13%] Building CXX object csrc/core/CMakeFiles/mmdeploy_core.dir/model.cpp.o
In file included from /usr/include/spdlog/fmt/fmt.h:25,
                 from /usr/include/spdlog/common.h:36,
                 from /usr/include/spdlog/spdlog.h:12,
                 from /home/nihui/osd/MMDeploy/csrc/core/logger.h:6,
                 from /home/nihui/osd/MMDeploy/csrc/core/model.cpp:5:
/usr/include/fmt/core.h: 在成员函数‘mmdeploy::Result<void> mmdeploy::Model::Init(const void*, size_t)’中:
/home/nihui/osd/MMDeploy/csrc/core/model.cpp:59:5:   in ‘constexpr’ expansion of ‘fmt::v8::basic_format_string<char, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>("{} successfully load sdk model {}")’
/usr/include/fmt/core.h:3069: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, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >(((fmt::v8::basic_format_string<char, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>*)this)->fmt::v8::basic_format_string<char, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>::str_, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(fmt::v8::basic_string_view<char>(((const char*)s)), (fmt::v8::detail::error_handler(), fmt::v8::detail::error_handler())))’
/usr/include/fmt/core.h:2661:36:   in ‘constexpr’ expansion of ‘fmt::v8::detail::parse_replacement_field<char, fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&>(p, end, (* & handler))’
/usr/include/fmt/core.h:2592:51:   in ‘constexpr’ expansion of ‘(& handler)->fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::on_arg_id()’
/usr/include/fmt/core.h:2911:70:   in ‘constexpr’ expansion of ‘((fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)this)->fmt::v8::detail::format_string_checker<char, fmt::v8::detail::error_handler, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::context_.fmt::v8::detail::compile_parse_context<char, fmt::v8::detail::error_handler>::next_arg_id()’
/usr/include/fmt/core.h:2698:40: 错误:‘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
 2698 |     if (id >= num_args_) this->on_error("argument not found");
      |                          ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/fmt/core.h:692:22: 附注:‘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:
  692 |   FMT_CONSTEXPR void on_error(const char* message) {
      |                      ^~~~~~~~
/usr/include/fmt/core.h:693:27: 错误:call to non-‘constexpr’ function ‘void fmt::v8::detail::error_handler::on_error(const char*)’
  693 |     ErrorHandler::on_error(message);
      |     ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/usr/include/fmt/core.h:618:29: 附注:‘void fmt::v8::detail::error_handler::on_error(const char*)’在此声明
  618 |   FMT_NORETURN FMT_API void on_error(const char* message);
      |                             ^~~~~~~~
make[2]: *** [csrc/core/CMakeFiles/mmdeploy_core.dir/build.make:132:csrc/core/CMakeFiles/mmdeploy_core.dir/model.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:718:csrc/core/CMakeFiles/mmdeploy_core.dir/all] 错误 2
make: *** [Makefile:136:all] 错误 2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions