-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Compile error with example from documentation #2522
Comments
Can reproduce the failure on master branch. |
I was having similar issues. The error is because fmtlib (>=8.0?) assumes constexpr for the format string. To pass a runtime format string, this is needed: `fmt::format(fmt::runtime(some_runtime_string), ...). |
with C++20 enabled. I'm not sure why only GCC 11+ and Clang 12+ fail here, maybe a build system passes Regarding passing a runtime format string, I can propose another option: keeping compile-time checks with one Anyway, this example from documentation should be fixed if it's still available. |
Ok, thank you! |
The example is fixed now: https://fmt.dev/dev/api.html#formatting-user-defined-types. Thanks for reporting. |
Maybe the documentation is fixed, but how does one report an error during parsing? throw format_error fails since throw is not allowed in a constexpr function. |
throw should work and give the desired behavior, either a compile-time error or a runtime error. |
GCC fails with:
This example from the documentation fails to compile with both GCC 11 and clang 12 but not in previous versions.
The text was updated successfully, but these errors were encountered: