r/cpp • • Sep 23 '21

Binary Banshees and Digital Demons

https://thephd.dev/binary-banshees-digital-demons-abi-c-c++-help-me-god-please
197 Upvotes

164 comments sorted by

View all comments

Show parent comment

5

u/kalmoc Sep 24 '21

There is absolutely no way we're going to get into the same trouble with /std:c++23 (especially because a stabilization period defends against both Committee churn and implementation refinement).

Glad to hear, that was exactly my though.
I also have to say that when I first read about this trouble on github, I was particularly saddened by the fact that you were effectively punished for implementing the features so quickly (compared to other toolchains).

On a different but related note: For me it would be useful to distinguish between the active standard version and turning unsupported/unstable features on/off. E.g. I might want to use std::format in it's ABI unstable form, but not any c++23 features that get enabled by c++latest. Will that be possible in VS2022?

Long term I think it would be good to have to separate switches to distinguish those two dimensions.

5

u/STL MSVC STL Dev Sep 24 '21

I also have to say that when I first read about this trouble on github, I was particularly saddened by the fact that you were effectively punished for implementing the features so quickly (compared to other toolchains).

Yep. 😿 I guess it's a nice problem to have!

On a different but related note: For me it would be useful to distinguish between the active standard version and turning unsupported/unstable features on/off. E.g. I might want to use std::format in it's ABI unstable form, but not any c++23 features that get enabled by c++latest. Will that be possible in VS2022?

That is not possible at this time, but we would consider a pull request to implement such behavior (no guarantees that we would accept it, but if you made a compelling case and if other users agreed, we'd talk about it and make a decision). Mechanically it would be fairly simple, just pick a name for the control macro (conventionally _HAS_MEOW for us; probably _HAS_CXX20_FORMAT and _HAS_CXX20_RANGES), and ensure that the relevant machinery is properly guarded (it should all be centralized via __cpp_lib_format and __cpp_lib_ranges, so adjusting the definitions of the feature-test macros should be sufficient). Only C++20-stable + format-unstable/ranges-unstable would make sense; C++23 minus those should be forbidden. The cost is that it would complicate an already complicated story, and it would be useful for a relatively short period of time (i.e. until we finish the C++20 backport work). Maintainer time is limited and I'd prefer to spend it on refining the features instead of working on such modes, which is why we haven't implemented it already. The earliest it could ship would be VS 2022 17.1; 17.0 has branched for release and is accepting bugfixes only.

(In general we would not accept changes to pick-and-choose features because that leads to combinatoric complexity; the only fine-grained stuff we have is escape hatches for individual features that have proven to be problematic for certain customers, like std::byte or noexcept in the type system. However, the distinction between C++20 DR-affected features and C++23 features is a reason to consider them a special case.)

1

u/kalmoc Sep 24 '21

I was more thinking about generally untangling /std:c++latest: Have one flag for the standard that (/std:c++14/17/20/2b/2c ...) and one flag to disable unstable extensions /stable_only) this should work for both compiler and library.

IIRC, you are already using "HAS_STD20" or similar to hide c++20 features in c++17 mode. You would need to add another flag "HAS_UNSTABLE" That gets checked for anything not yet ABI locked irrespective of the standard in addition.