Details
-
Bug
-
Resolution: Won't Do
-
Not Evaluated
-
None
-
5.15.17, 6.8.0 Beta4
-
None
-
Debian 12 amd64
gcc (Debian 10.2.1-6) 10.2.1 20210110
(C++17, C++20 mode)
Description
If we want to use std::x64_t types for parsing binary data using QDataStream, and then put values it into QVariant for whatever reason, we get compilation error for using std::int64_t or std::uint64_t:
error: ambiguous overload for ‘operator<<’ (operand types are ‘QDataStream’ and ‘int64_t’ {aka ‘long int’})
error: ambiguous overload for ‘operator<<’ (operand types are ‘QDataStream’ and ‘uint64_t’ {aka ‘long unsigned int’})
error: no match for ‘operator>>’ (operand types are ‘QDataStream’ and ‘int64_t’ {aka ‘long int’})
error: no match for ‘operator>>’ (operand types are ‘QDataStream’ and ‘uint64_t’ {aka ‘long unsigned int’})
error: call of overloaded ‘QVariant(<brace-enclosed initializer list>)’ is ambiguous
Code example:
#include <QByteArray> #include <QDataStream> #include <QDebug> #include <QIODevice> #include <QVariant> int main() { QByteArray buffer; QDataStream ds{&buffer, QIODevice::ReadWrite}; ds << std::int8_t{1}; ds << std::int16_t{2}; ds << std::int32_t{3}; ds << std::int64_t{4}; ds << std::uint8_t{10}; ds << std::uint16_t{11}; ds << std::uint32_t{12}; ds << std::uint64_t{13}; std::int8_t a; std::int16_t b; std::int32_t c; std::int64_t d; std::uint8_t a2; std::uint16_t b2; std::uint32_t c2; std::uint64_t d2; ds.device()->seek(0); ds >> a; ds >> b; ds >> c; ds >> d; ds >> a2; ds >> b2; ds >> c2; ds >> d2; qDebug() << QVariant{a}; qDebug() << QVariant{b}; qDebug() << QVariant{c}; qDebug() << QVariant{d}; qDebug() << QVariant{a2}; qDebug() << QVariant{b2}; qDebug() << QVariant{c2}; qDebug() << QVariant{d2}; }
I see no reason why this inconsistency should exist, as it works fine with 8/16/32_t.
Attachments
Issue Links
- is duplicated by
-
QTBUG-129380 Possibility to work with int64_t and uint64_t for QDataStream
- Closed
- relates to
-
QTBUG-86424 Can not use enum (class) as slot argument with underlying type (unsigned) long, e.g. std::uint64_t
- Closed
-
QTBUG-129217 quint64 differs from uint64_t
- Closed