-
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
fmt/chrono.h: use of deprecated std::codecvt class template which is deprecated as of C++20 #2408
Comments
A PR to suppress the warning is welcome. |
While With that being said, would you prefer just a local pragma push/pop of |
A local pragma would be fine. Using deprecated API is OK here because it's a legacy path anyway and even if it is removed (which is unlikely) there is a reasonable fallback. Besides |
Suppressed the warning in d57b2a6. Thanks for reporting. |
This hasn't been fixed.
|
I guess we could replace the two uses of the |
Ok, done #2725 |
As of C++20, the class template speciailization
std::codecvt<char32_t, char, std::mbstate_t>
is deprecated in favor of usingchar8_t
:std::codecvt<char32_t, char8_t, std::mbstate_t>
.The line causing this warning is chrono.h. This warning was noticed when using
llvm12
withlibc++
in C++20 mode (c++2a
) aslibc++
marks the class template as deprecated per the C++20 spec.Some notes regarding a potential patch for this:
do_write
function currently returns astd::string
. One approach to solving this problem is to change thisdo_write
function to work withchar
orchar8_t
consistently based on compiler support forchar8_t
. This would mean that the return type is nowstd::string
orstd::basic_string<char8_t>
. Consider the following snippet:std::time_put
notably should usechar
still rather thanchar_t
. There is no overload forstd::time_put<char8_t>
which is an oversight I think whenchar8_t
got proposed. It can be added in a future paper which I may propose.Note: I recommend working with
char_t
as described above throughout to avoid UB. Whilechar
andchar8_t
are the same size, alignment, etc, it is UB toreinterpret_cast
different types (e.g. astd::string
to astd::basic_string<char8_t>
) for example as returned from thestringstream.str()
call.With the return type of
do_write
being astd::string
orstd::basic_string<char8_t>
now, I don't yet know how this affects the calling code copies the string to the output iterator.The text was updated successfully, but these errors were encountered: