From 4912903e37b6739d05d4d4acf405470c541199e1 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 5 May 2022 16:21:46 +0200 Subject: Endian: Remove old special integer bitfields The only way to use them was to put them in a union and then write all the members of the union to set the various bit ranges. As only one member of a union can be active at any time, the compiler is free to optimize those writes away, though. This has started happening in the wild now. As we have a replacement, we can remove the old and broken code now. Task-number: QTBUG-99545 Change-Id: I90718ec06662258d1c15220f54da9eed2186c5a5 Reviewed-by: Thiago Macieira --- .../auto/corelib/global/qtendian/tst_qtendian.cpp | 29 ---------------------- 1 file changed, 29 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/global/qtendian/tst_qtendian.cpp b/tests/auto/corelib/global/qtendian/tst_qtendian.cpp index e688768b74..401367ecaa 100644 --- a/tests/auto/corelib/global/qtendian/tst_qtendian.cpp +++ b/tests/auto/corelib/global/qtendian/tst_qtendian.cpp @@ -35,8 +35,6 @@ private slots: void endianIntegers_data(); void endianIntegers(); - void endianBitfields(); - void endianBitfieldUnions_data(); void endianBitfieldUnions(); }; @@ -344,33 +342,6 @@ void tst_QtEndian::endianIntegers() #endif } -void tst_QtEndian::endianBitfields() -{ - union { - quint32_be_bitfield<21, 11> upper; - quint32_be_bitfield<10, 11> lower; - qint32_be_bitfield<0, 10> bottom; - } u; - - u.upper = 200; - QCOMPARE(u.upper, 200U); - u.lower = 1000; - u.bottom = -8; - QCOMPARE(u.lower, 1000U); - QCOMPARE(u.upper, 200U); - - u.lower += u.upper; - QCOMPARE(u.upper, 200U); - QCOMPARE(u.lower, 1200U); - - u.upper = 65536 + 7; - u.lower = 65535; - QCOMPARE(u.lower, 65535U & ((1<<11) - 1)); - QCOMPARE(u.upper, 7U); - - QCOMPARE(u.bottom, -8); -} - template typename Union, template typename Member> void testBitfieldUnion() { -- cgit v1.2.3