-
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
Compile failure with MSVC with /W4 /WX - ostream.h(153): warning C4127: conditional expression is constant #4314
Comments
Fixing all possible warnings (especially level 4 which have tons of false positive) is a non-goal but you can suppress them with FMT_SYSTEM or other means. |
I also ran into this while bumping the dependency verison, wouldn't something like following solve the problem? if FMT_CONSTEXPR (detail::use_utf8) return vprint(os, fmt.str, vargs); This will probably not work for C++14 so it might be worth to have FMT_CONSTEXPR17 just like FMT_CONSTEXPR20 Another benefit would be that this condition is shifted to compile time and not runtime, I know optimizations are pretty clever but that will not happen for debug builds while with constexpr it will be a certain thing. |
Use Line 2913 in aabe639
|
Does that mean I should create a PR? We consume the library directly from this repo so a local patch wouldn't be ideal. |
Also it seems that |
A PR to add |
The following Code doesn't compile with 'Treat warnings as errors' and warning level 4:
compiling with cl /EHsc /std:c++20 /W4 /WX /utf-8 x.cpp /MDd /I D:\libs\fmt\include D:\libs\fmt\x64\Debug\fmtd.lib gives:
D:\libs\fmt\include\fmt/ostream.h(153): error C2220: the following warning is treated as an error
D:\libs\fmt\include\fmt/ostream.h(153): warning C4127: conditional expression is constant
D:\libs\fmt\include\fmt/ostream.h(153): note: consider using 'if constexpr' statement instead
The problem is this if in print because detail::use_utf8 is a compile time constant
Changing print this way might solve the problem for C++17 and higher but doesn't compile with C++14
The text was updated successfully, but these errors were encountered: