[Development] Raising the minimum to C++20

Thiago Macieira thiago.macieira at intel.com
Fri May 5 18:14:35 CEST 2023


On Friday, 5 May 2023 03:18:46 PDT Ville Voutilainen wrote:
> > Of the C++20 features I currently see a good reason to make mandatory:
> > * feature-test macros (no change: we're already using them)
> > * spaceship operator and <compare> header
> > * char8_t
> > * std::is_constant_evaluated()
> > * constinit
> > * <bit> header
> > * (maybe) designated initialisers
> > * (maybe) constexpr from <algorithm> and <utility>
> 
> I don't see any of these as worth breaking embedded users who want new
> Qt versions but don't yet
> have the compilers that can give them these facilities.

When you put it this way, no, they're not worth *breaking* the experience for 
those users. We're already using the feature-test macros and constinit even in 
C++17 mode, we have our own implementation for what <bit> does (but see 
below). We also have conditional code for std::is_constant_evaluated() and a 
fallback to a GCC extension, and Ivan was beginning to add a fallback/
workaround for the spaceship operator with macros[1]. The latter is why I 
began this thread: I'd like to know if we should "dirty" our code with more 
macros or if we can go clean for the spaceship.

The only odd result is that one compiler (MSVC) is generating worse code 
because we don't have access to the builtins that <bit> and 
std::is_constant_evaluated() would have used. That's fixable.

One, __builtin_is_constant_evaluated() works with GCC 9, Clang 10, MSVC 2019 
and even the old EDG-based Intel compiler in C++17 mode, see
	https://gcc.godbolt.org/z/4boM5Esfx
So we *could* just use it and damn the torpedoes. That leaves out users of GCC 
8 (a.k.a. QNX) and the GHS compiler, who would get non-constexpr code 
generation.

Two, we could simply raise MSVC or just all Windows builds to C++20 regardless 
of what we do elsewhere. During Qt 4 days, after we switched to C++11, we did 
begin using some core language and standard library features without compiler 
check in macOS-specific code because we knew the state of that compiler.

I think is a fair deal: we get to move forward and improve the platforms that 
can upgrade, without affecting the ones that can't.


[1] https://codereview.qt-project.org/c/qt/qtbase/+/475447

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230505/a95739e8/attachment.bin>


More information about the Development mailing list