Repository navigation
Description
We're in a novel situation: never before have we completed a Standard so rapidly. Adding to this concern, <format> is both ABI-sensitive and performance-sensitive, and WG21 is expected to mandate ABI-breaking changes soon.
(C++17 was different; we finished <charconv> in 2019 having completed all other features much earlier, and while it was performance-sensitive, we had time to extensively test and tune it, and its function-oriented nature means that it has no ABI concerns and can be revised in the future.)
We were initially planning to declare ABI stability when finishing C++20 (along with the addition of /std:c++20 as distinct from the always-experimental /std:c++latest), to align with the user expectation that non-experimental features supported for production use are also ABI stable. However, if this locks us into an implementation that can't keep up with retroactive changes to C++20, or freezes an implementation before it's had a chance for significant performance tuning, that will ultimately be harmful to users.
We should consider asking our bosses and boss-like entities for a change of plans: we will still declare C++20 to be feature-complete and ready for production use when we're done (as indicated by the feature-test macros), but we can announce that its ABI will potentially change for some defined period of time (3 months, 6 months, 1 year?) or number of releases (e.g. Dev17 17.x for some specific value of X). This will have no effect for /std:c++14 and /std:c++17 users, and we can expect that, at least initially, the population of /std:c++20 users will be the most eager upgraders for whom rebuilding the world is the least onerous.
Additionally, to mitigate mix-and-match problems, we could add a #pragma detect_mismatch to <format> right now, allowing us to revise it in the future and have the linker detect any OBJ/static LIB mixing.
Activity
sylveon commentedon Apr 9, 2021
I personally think something like keeping the ABI unstable until the non-preview release of Dev17 would be a good idea.
Freezing it now will lead to major differences between standard libraries because the new changes to the standard library require ABI breakage, meaning some libraries and consumers might be reluctant to adopting C++20 because of inconsistency between compilers/standard library implementations, and this will ultimately be detrimental to the MSVC ecosystem.
timsong-cpp commentedon Apr 9, 2021
As Barry Revzin (@brevzin) noted, there are three Ranges papers in flight with ABI implications as well (split, default construction, and join).
jovibor commentedon Apr 9, 2021
Nothing but hoping for your bosses' good sanity😎
hatcat commentedon Apr 9, 2021
I have high hopes for C++23...
miscco commentedon Apr 9, 2021
Will be finished in 22
Lectem commentedon Apr 9, 2021
If this can help take a decision or convince anybody:
Out of the 5 last clients I worked with, 4 said they stopped using some of STL types due to either runtime performance or compile time performance, that could be fixed by changing ABI such as is done in vNext. I'm thinking mainly about debug iterators and regexp.
If
std::formatisn't fast enough (to compile or at runtime) compared to fmt::format, I'm afraid this will only keep fueling arguments against using the STL (and std library in general, whatever implementation it is).While I am sympathetic to having some kind of ABI stability, I don't think "rushing" a release just to be able to put the "c++ latest compliant" stamp is a good idea if QoI improvements can't follow due to the same ABI stability.
An upgrade path must be kept, or some rupture planned to finally take this opportunity to break ABI, just as was done in the past.
MikeGitb commentedon Apr 10, 2021
Personally, I'm not even that concerned about performance, exactly because there is fmt and the STL is rarely the best performing solution for a given problem anyway.
What I do care about though is correctness and portability. Effectively locking down the ABI before having any significant user contact, real-world testing and (ideally) a second implementation to compare against seems a very risky choice for something so fundamental - especially when people are still trying to "fix" the standard itself.
jovibor commentedon Apr 10, 2021
By this logic, there is no value in using STL at all, because every piece of it has more performant counterpart somewhere anyway. The only reason would be that it's available out-of-the box.
If the performance question is not about years of researching or some rocket science, but only delaying ABI locking by month or so I would definitely consider it as the way to go.
MikeGitb commentedon Apr 10, 2021
That's pretty much the way it is. Yes. Except for
Just because there is something faster somewhere doesn't mean the STL doesn't have value. Using 3rd party dependencies comes with it's own costs and even in c++ code, performance is not the only relevant metric.
But that gets off topic.
vitaut commentedon Apr 12, 2021
It's more complicated in case of fmt/
std::formatcompared to, say, containers because here we have theformatterextension point. It would be really unfortunate if we ended up in the world with two sets of incompatibleformatterspecializations and resulting interoperability problems. I think it's worth taking time and addressing performance differences before ABI is frozen or at least making sure that they can be addressed in the future without ABI breakage.MikeGitb commentedon Apr 13, 2021
So far we have rarely been using a library provided
operator<<for printing (except for printf debugging or quick prototyping), because most of the time we had our own format requirements anyway. In a similar fashoin, I'm not sure how much I'm going to use a 3rd partyfmt/std::formatterspecialization in a context, where performance matters. Also, performance aside, I expect fmt to stay ahead of std::format feature and compatibility wise for the forseable future, so we'll probably have to live with this duality for quite some time anyway.Anyway, as I wrote previously: I'm also very much against locking down the ABI right away - just that performance isn't my primary reason for that.
vitaut commentedon Apr 13, 2021
You maybe, others have been using them extensively.
The important thing is the long term, not the next few years. In the long term I expect
fmt::formatterto go away.42 remaining items
Allow access to range / format
Strike "with concepts support" from the GH-1814 messages (#2382)
Move <ranges> and <format> into C++20
Move `<ranges>` and `<format>` into C++20 (#2518)
CaseyCarter commentedon Feb 7, 2022
FYI, I've closed this issue despite that there's still work to be done to backport
<ranges>and<format>to VS 2019 16.11, because all of the work that will take place in this repository is now complete.SamVanheer commentedon Feb 11, 2022
Since this issue is closed, is #2492 the issue to keep an eye on for the backporting work?
[Multiple Changes to Config.cmake]
GF-Huang commentedon May 3, 2022
Why I can't use
std::formatin VS2022? Namespacestdhas no memberformat!!!sylveon commentedon May 3, 2022
std::format under /std:c++20 is available in VS 17.2. For now, 17.2 is in preview. It should release to the stable branch at some point.
JonSuper commentedon May 20, 2022
需要 VS 2019 16.11.14 or VS 2022 17.2 above
StephanTLavavej commentedon May 22, 2022
Maxer (@JonSuper) It should be present in those versions. Are you sure you're looking at the properties for the configuration that you're actually building? I recommend looking at the build log and verifying whether
/std:c++20is on the command line.You can also inspect the STL's macros to check its version and Standard mode. Include
<version>and test_MSVC_STL_UPDATE- it should be exactly202105Lfor VS 2019 16.11.14 or any later patch, and it should be202203Lor greater for VS 2022 17.2 or greater. Finally, after including<version>, you can inspect_HAS_CXX20which will be defined to1if the STL believes that it's in C++20 mode (otherwise it will be0).Hopefully this should allow you to track down whether you're using an unexpected version or an unexpected compiler option.
JonSuper commentedon May 24, 2022
@StephanTLavavej
It will compiled fail while using VS 2022 17.2 with Visual Studio 2019 (v142) Toolset
the yvals_core.h here :
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395 and GH-1814
#define __cpp_lib_format 201907L
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)
but using VS 2019 16.11.15 with Visual Studio 2019 (v142) Toolset is OK
StephanTLavavej commentedon May 25, 2022
Ah, then the issue is that the VS 2022 IDE's selectable option of the VS 2019 v142 toolset hasn't been updated to the 16.11.14 or later bits. I believe this will happen at some point but I don't have an ETA.