[Development] QJsonPrivate::Parser::parseObject broken on big endian

Konstantin Tokarev annulen at yandex.ru
Sun Sep 2 21:10:18 CEST 2012


Hi all,

When building Qt 5 on big endian host (PPC) I've found moc breaking on Qt classes containing Q_PLUGIN_METADATA with

ASSERT: "idx >= 0 && idx < s" in file ../../../include/QtCore/../../src/corelib/tools/qvarlengtharray.h, line 111

It turned out to be a fault of QJsonPrivate::Parser::parseObject which has different code for handling of big endian and little endian cases:

    if (parsedObject.offsets.size()) {
        int tableSize = parsedObject.offsets.size()*sizeof(uint);
        table = reserveSpace(tableSize);
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
        memcpy(data + table, parsedObject.offsets.constData(), tableSize);
#else
        offset *o = (offset *)(data + table);
        for (int i = 0; i < tableSize; ++i)
            o[i] = parsedObject.offsets[i];

#endif
    }

Could anyone explain why memcpy cannot be used for big endian case here?

-- 
Regards,
Konstantin



More information about the Development mailing list