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

static_assert failure when used with fmt 9.0.0+ #366

Closed
carlocab opened this issue Jul 24, 2022 · 4 comments
Closed

static_assert failure when used with fmt 9.0.0+ #366

carlocab opened this issue Jul 24, 2022 · 4 comments
Labels

Comments

@carlocab
Copy link

carlocab commented Jul 24, 2022

Describe the bug
Using Sophus with fmt 9.0.0+ produces the following error:

  In file included from /tmp/sophus-test-20220724-36730-72obh/HelloSO3.cpp:2:
  In file included from /opt/homebrew/include/sophus/geometry.hpp:6:
  In file included from /opt/homebrew/include/sophus/se2.hpp:6:
  In file included from /opt/homebrew/include/sophus/so2.hpp:12:
  In file included from /opt/homebrew/include/sophus/rotation_matrix.hpp:9:
  In file included from /opt/homebrew/include/sophus/types.hpp:7:
  In file included from /opt/homebrew/include/sophus/common.hpp:35:
  In file included from /opt/homebrew/include/fmt/format.h:48:
  /opt/homebrew/include/fmt/core.h:1732:3: error: static_assert failed due to requirement 'formattable' "Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt"
    static_assert(
    ^

To Reproduce
Install fmt 9.0.0, and then try to use Sophus. For example, the following makes use of HelloSO3.cpp:

# CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(HelloSO3)
find_package(Sophus REQUIRED)
add_executable(HelloSO3 HelloSO3.cpp)
target_link_libraries(HelloSO3 Sophus::Sophus)

Running the above CMakeLists.txt with HelloSO3.cpp in your current working directory with cmake . && make produces the error shown above.

Expected behavior
No error.

Sophus version: 4ac843d

I haven't found time to test on HEAD yet, but the changes to the files in the call stack since this commit hash don't look to have fixed the issue.

Additional context

So far I've reproduced this on macOS 11 with Apple-provided Clang, but I don't think this is specific to that.

@carlocab carlocab added the bug label Jul 24, 2022
@LiuPeiqiCN
Copy link

Same issue.
I define SOPHUS_USE_BASIC_LOGGING before include sophus header to disable fmt temporarily.

@strasdat
Copy link
Owner

yeah, fmt 9.0.0 seems broken. fmtlib/fmt#2936

I suggest to revert to 8.1.1 or try HEAD of master: https://github.com/fmtlib/fmt/

@NikolausDemmel
Copy link
Contributor

From the 9.0.0 release notes, this item seem like it might be the cause for the error. It sounds like that won't go away with future fmt versions, so at some point Sophus should adapt to it (ideally while staying compatible to older versions of fmt).

Disabled automatic std::ostream insertion operator (operator<<) discovery when fmt/ostream.h is included to prevent ODR violations. You can get the old behavior by defining FMT_DEPRECATED_OSTREAM but this will be removed in the next major release. Use fmt::streamed or fmt::ostream_formatter to enable formatting via std::ostream instead.

To test one could define FMT_DEPRECATED_OSTREAM, but that would just be a temporary workaround.

@carlocab
Copy link
Author

carlocab commented Oct 13, 2022

For future reference, this was fixed in #376. (At the very least, this is fixed in the latest version of Sophus.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants