[Development] Houston, qint128 has a problem
Marc Mutz
marc.mutz at qt.io
Sat Dec 9 03:51:19 CET 2023
Hi,
After spending countless hours between Ivan and myself fighting GCC's
mysteriously-vanishing <type_traits> support for __int128_t (= qint128),
it turns out that with -ansi/-std=c++NN, not even the most basic of
<type_traits> work: std::is_signed_v<qint128> is _false_! I repeat: _FALSE_.
The following is /my/ professional opinion, Ivan may chime in himself:
I think we need to mandate that if you want qint128 support, then you
must compile with gnu++NN, which is actually the default on both GCC and
Clang. We seem to switch that off (-ansi on).
We cannot fight a broken stdlib. If the compiler says that these things
don't exist as integral types, then who is Qt to disagree? It slows down
development, and all those work-arounds slow down compilations, too:
- std::is_integral_v<T>
+ std::disjunction_v<std::is_integral<T>,
+ std::is_same<T, qint128>,
+ std::is_same<T, quint128>>
Unless someone can present a solution where <type_traits> and <limits>
work for q(u)int128 under -ansi — even for users — I would undef
QT_SUPPORTS_INT128 when __STRICT_ANSI__ is in effect, then drop the
-ansi from Qt builds to make sure the symbols that contain qint128 are
present in the library. User projects can then use whichever one they want.
We have a similar issue with qfloat16::NativeFloat. On GCC-13, the
traits only work (tested: <limits>) when compiling in C++23 mode, yet we
insist on using the types before, eagerly grabbing _some_ definition
from wherever we can (C20, platform-specifics, ...).
And yes, that means we'll have BC issues from that, too.
References:
- https://bugreports.qt.io/browse/QTBUG-119901
-
https://codereview.qt-project.org/c/qt/qtbase/+/478199/comment/bcbe8aca_d5d65018/
- https://codereview.qt-project.org/c/qt/qtbase/+/507383
Opinions? Comments?
Thanks,
Marc
--
Marc Mutz <marc.mutz at qt.io>
Principal Software Engineer
The Qt Company
Erich-Thilo-Str. 10 12489
Berlin, Germany
www.qt.io
Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht Charlottenburg,
HRB 144331 B
More information about the Development
mailing list