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

v8 regression when compiling with FMT_USE_USER_DEFINED_LITERALS=0 #2384

Closed
mbunkus opened this issue Jun 25, 2021 · 5 comments
Closed

v8 regression when compiling with FMT_USE_USER_DEFINED_LITERALS=0 #2384

mbunkus opened this issue Jun 25, 2021 · 5 comments

Comments

@mbunkus
Copy link

mbunkus commented Jun 25, 2021

The following small test program can be compiled just fine with e.g. 7.1.3, but it fails with 8.0.0:

#define FMT_USE_USER_DEFINED_LITERALS 0

#include <fmt/format.h>

int main() {
  return fmt::format("hello {0}", "world").size();
}

Error message with 8.0.0 & gcc 11:

/home/mosu/prog/video/mkvtoolnix/lib/fmt/include/fmt/format.h:2752:64: error: no template named 'udl_arg' in namespace 'fmt::v7::detail'
constexpr auto operator"" _a(const char* s, size_t) -> detail::udl_arg<char> {
                                                       ~~~~~~~~^
/home/mosu/prog/video/mkvtoolnix/lib/fmt/include/fmt/format.h:2753:11: error: cannot initialize return object of type 'int' with an lvalue of type 'const char *'
  return {s};
          ^
/home/mosu/prog/video/mkvtoolnix/lib/fmt/include/fmt/format.h:2768:16: error: no template named 'udl_formatter' in namespace 'fmt::v7::detail'
    -> detail::udl_formatter<char> {
       ~~~~~~~~^
/home/mosu/prog/video/mkvtoolnix/lib/fmt/include/fmt/format.h:2769:11: warning: too many braces around scalar initializer [-Wmany-braces-around-scalar-init]
  return {{s, n}};
          ^~~~~~
/home/mosu/prog/video/mkvtoolnix/lib/fmt/include/fmt/format.h:2769:12: error: cannot initialize return object of type 'int' with an lvalue of type 'const char *'
  return {{s, n}};
           ^

I've built without user-defined literals for years now because a) my program doesn't use them and b) there are a lot of warnings with -Wpedantic and user-defined literals activated (and I'm somewhat anal about warnings).

@alexezeder
Copy link
Contributor

This probably will be fixed by #2376.

@DanielaE
Copy link
Contributor

May be some additional tests for these specific compilation environments are in order.

github-actions bot pushed a commit to THIS-IS-NOT-A-BACKUP/MKVToolNix that referenced this issue Jun 25, 2021
fmt v8 currently contains a bug that causes compilation to fail if
`FMT_USE_USER_DEFINED_LITERALS` is defined to 0. This is a regression
from earlier versions. A bug has been filed against fmt:

fmtlib/fmt#2384

MKVToolNix defined this to 0 as earlier fmt versions caused warnings
in their code dealing with user-defined literals with
`-Wpedantic`. Luckily those warnings do not occur with v8 anymore.

The fix is to test in `configure` if the fmt version we're compiling
with is v8 or older, and only to define
`FMT_USE_USER_DEFINED_LITERALS` to 0 for earlier versions.

Fixes #3151.
@vitaut
Copy link
Contributor

vitaut commented Jun 26, 2021

Fixed in #2376, thanks for reporting.

@vitaut vitaut closed this as completed Jun 26, 2021
@mbunkus
Copy link
Author

mbunkus commented Jun 26, 2021

Thanks for fixing this one so quickly in particular and all the work you've all done of this fantastic library in particular. Over the years my MKVToolNix has used the printf family, the C++ I/O streams and Boost's format before finally discovering and convert to fmt. It is so well designed, such a joy to work with, so fast and type-safe on top of it that I pretty much recommend it to everyone doing C++ things. Again, thank you all so much!

@vitaut
Copy link
Contributor

vitaut commented Jun 26, 2021

Thanks @zx2c4 for the actual fix =).

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