-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Check dynamic precision at compile time #1614
Comments
You need to wrap the format string in |
It still doesn't work for me. This compiles, even though it's CLEARLY missing a parameter.
This is what it should be without bugs:
What else am I doing wrong? |
Looks like the check in dynamic precision is missing. |
Also, I found some other strange behaviour:
Result:
|
If you are asking whether the default and
Normally yes. |
Invalid argument ids in dynamic width/precision are now reported at compile time. For example #include <fmt/format.h>
int main() {
fmt::print(FMT_STRING("{0:{1}}"), 42);
} gives a compilation error because argument 1 doesn't exist:
|
I'm probably an idiot, but isn't fmt supposed to check parameters at compile time for safety?
I have this code (which compiles without errors):
Of course, this crashed at run-time because I was missing the length parameter.
This fixes it:
Why didn't I get a compile-time error?
Do I need to change a preprocessor switch to enable compile-time checking of the parameters?
The text was updated successfully, but these errors were encountered: