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

‘fmt’ is not a constant expression #950

Closed
bigwhite37 opened this issue Sep 22, 2021 · 1 comment
Closed

‘fmt’ is not a constant expression #950

bigwhite37 opened this issue Sep 22, 2021 · 1 comment

Comments

@bigwhite37
Copy link

When I compiled seastar on ubuntu 21.04 with gcc 11.2.0, the configure command is,

$ ./configure.py --mode=debug --c++-dialect=c++2b

then I got the compile error:

In file included from /root/code/cu/seastar/include/seastar/util/backtrace.hh:30,
                 from /root/code/cu/seastar/include/seastar/core/task.hh:26,
                 from /root/code/cu/seastar/include/seastar/core/future.hh:24,
                 from /root/code/cu/seastar/include/seastar/core/semaphore.hh:24,
                 from /root/code/cu/seastar/src/core/semaphore.cc:23:
/root/code/cu/seastar/include/seastar/core/print.hh: In instantiation of ‘seastar::sstring seastar::format(const char*, A&& ...) [with A = {std::basic_string_view<char, std::char_traits<char> >&}; seastar::sstring = seastar::basic_sstring<char, unsigned int, 15>]’:
/root/code/cu/seastar/src/core/semaphore.cc:70:22:   required from here
/root/code/cu/seastar/include/seastar/core/print.hh:136:19:   in ‘constexpr’ expansion of ‘fmt::v8::basic_format_string<char, std::basic_string_view<char, std::char_traits<char> >&>(fmt)’
/root/code/cu/seastar/include/seastar/core/print.hh:136:19: error: ‘fmt’ is not a constant expression
  136 |     fmt::format_to(out, fmt, std::forward<A>(a)...);
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 17%] Building CXX object CMakeFiles/seastar.dir/src/http/routes.cc.o
make[2]: *** [CMakeFiles/seastar.dir/build.make:508: CMakeFiles/seastar.dir/src/core/semaphore.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /root/code/cu/seastar/src/core/memory.cc:57:
/root/code/cu/seastar/include/seastar/core/print.hh: In instantiation of ‘seastar::sstring seastar::format(const char*, A&& ...) [with A = {long unsigned int&, long unsigned int&}; seastar::sstring = seastar::basic_sstring<char, unsigned int, 15>]’:
/root/code/cu/seastar/src/core/memory.cc:79:40:   required from here
/root/code/cu/seastar/include/seastar/core/print.hh:136:19:   in ‘constexpr’ expansion of ‘fmt::v8::basic_format_string<char, long unsigned int&, long unsigned int&>(fmt)’
/root/code/cu/seastar/include/seastar/core/print.hh:136:19: error: ‘fmt’ is not a constant expression
  136 |     fmt::format_to(out, fmt, std::forward<A>(a)...);
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /root/code/cu/seastar/include/seastar/util/backtrace.hh:30,
                 from /root/code/cu/seastar/src/core/on_internal_error.cc:23:
/root/code/cu/seastar/include/seastar/core/print.hh: In instantiation of ‘seastar::sstring seastar::format(const char*, A&& ...) [with A = {const char*, seastar::tasktrace}; seastar::sstring = seastar::basic_sstring<char, unsigned int, 15>]’:
/root/code/cu/seastar/include/seastar/util/backtrace.hh:187:58:   required from ‘seastar::internal::backtraced<Exc>::backtraced(Args&& ...) [with Args = {std::runtime_error}; Exc = std::runtime_error]’
/root/code/cu/seastar/include/seastar/util/backtrace.hh:215:67:   required from ‘std::__exception_ptr::exception_ptr seastar::make_backtraced_exception_ptr(Args&& ...) [with Exc = std::runtime_error; Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
/root/code/cu/seastar/include/seastar/util/backtrace.hh:231:62:   required from ‘void seastar::throw_with_backtrace(Args&& ...) [with Exc = std::runtime_error; Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
/root/code/cu/seastar/src/core/on_internal_error.cc:41:49:   required from here
/root/code/cu/seastar/include/seastar/core/print.hh:136:19:   in ‘constexpr’ expansion of ‘fmt::v8::basic_format_string<char, const char*, seastar::tasktrace>(fmt)’
/root/code/cu/seastar/include/seastar/core/print.hh:136:19: error: ‘fmt’ is not a constant expression
  136 |     fmt::format_to(out, fmt, std::forward<A>(a)...);
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This error maybe relate to this issue.

After I changing the code in print.hh which lead to compile error:

// before changing
fmt::format_to(out, fmt, std::forward<A>(a)...);

// after changing
fmt::format_to(out, fmt::runtime(fmt), std::forward<A>(a)...);

the compile error is fixed.

@deafwolf
Copy link

deafwolf commented Nov 4, 2021

looks this issue has been solved dfb6286

spjuanjoc added a commit to spjuanjoc/gui_project_cpp that referenced this issue Jul 15, 2023
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

3 participants