Bug 401494 - inefficient-qlist & inefficient-qlist-soft fail on 32bit Linux architectures
Summary: inefficient-qlist & inefficient-qlist-soft fail on 32bit Linux architectures
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-28 07:12 UTC by Pino Toscano
Modified: 2020-07-01 07:46 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pino Toscano 2018-11-28 07:12:59 UTC
SUMMARY
The inefficient-qlist, and 
tests fail when run on 32bit Linux architectures (e.g. armhf, i386, mips, and powerpc, in Debian).

STEPS TO REPRODUCE
1. build clazy on one of the aforementioned 32it Linux architectures
2. run the test suite, either from the build directory, or after installation

OBSERVED RESULT
These are the outputs on i386, and (sort of different name in library directory) they are the same also on the other affected architectures:

Qt version: 51102
Qt headers: /usr/include/i386-linux-gnu/qt5
Running: clang -Xclang -load -Xclang ClangLazy.so -Xclang -add-plugin -Xclang clang-lazy  -Xclang -plugin-arg-clang-lazy -Xclang no-inplace-fixits -Wno-unused-value -Qunused-arguments -std=c++14 -isystem /usr/include/i386-linux-gnu/qt5 -fPIC -L /usr/lib/i386-linux-gnu -c  -Xclang -plugin-arg-clang-lazy -Xclang inefficient-qlist -Xclang -plugin-arg-clang-lazy -Xclang enable-all-fixits inefficient-qlist/main.cpp
output_file=inefficient-qlist/main.cpp.out
[FAIL] inefficient-qlist
--- inefficient-qlist/main.cpp.expected 2018-09-23 16:22:24.000000000 +0000
+++ inefficient-qlist/main.cpp.result   2018-11-27 08:00:50.257341202 +0000
@@ -1,3 +1,4 @@
 inefficient-qlist/main.cpp:24:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist]
+inefficient-qlist/main.cpp:25:5: warning: Use QVector instead of QList for type with size 8 bytes [-Wclazy-inefficient-qlist]
 inefficient-qlist/main.cpp:38:11: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist]
 inefficient-qlist/main.cpp:40:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist]

Qt version: 51102
Qt headers: /usr/include/i386-linux-gnu/qt5
Running: clang -Xclang -load -Xclang ClangLazy.so -Xclang -add-plugin -Xclang clang-lazy  -Xclang -plugin-arg-clang-lazy -Xclang no-inplace-fixits -Wno-unused-value -Qunused-arguments -std=c++14 -isystem /usr/include/i386-linux-gnu/qt5 -fPIC -L /usr/lib/i386-linux-gnu -c  -Xclang -plugin-arg-clang-lazy -Xclang inefficient-qlist-soft -Xclang -plugin-arg-clang-lazy -Xclang enable-all-fixits inefficient-qlist-soft/main.cpp
output_file=inefficient-qlist-soft/main.cpp.out
[FAIL] inefficient-qlist-soft
--- inefficient-qlist-soft/main.cpp.expected    2018-09-23 16:22:24.000000000 +0000
+++ inefficient-qlist-soft/main.cpp.result      2018-11-27 08:00:46.469387068 +0000
@@ -1,3 +1,4 @@
 inefficient-qlist-soft/main.cpp:24:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist-soft]
+inefficient-qlist-soft/main.cpp:25:5: warning: Use QVector instead of QList for type with size 8 bytes [-Wclazy-inefficient-qlist-soft]
 inefficient-qlist-soft/main.cpp:64:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist-soft]
 inefficient-qlist-soft/main.cpp:68:5: warning: Use QVector instead of QList for type with size 9 bytes [-Wclazy-inefficient-qlist-soft]

Logs:
https://buildd.debian.org/status/fetch.php?pkg=clazy&arch=armhf&ver=1.4-2&stamp=1543305282&raw=1
https://buildd.debian.org/status/fetch.php?pkg=clazy&arch=i386&ver=1.4-2&stamp=1543305671&raw=1
https://buildd.debian.org/status/fetch.php?pkg=clazy&arch=mips&ver=1.4-2&stamp=1543387556&raw=1
https://buildd.debian.org/status/fetch.php?pkg=clazy&arch=powerpc&ver=1.4-2&stamp=1543305940&raw=1

EXPECTED RESULT
inefficient-qlist & inefficient-qlist-soft pass on any architecture.
Comment 1 Sergio Martins 2018-12-01 15:53:01 UTC
Git commit 9713a15f65424f06e45c78fc1bf1c2d2b27f4e36 by Sergio Martins.
Committed on 01/12/2018 at 15:52.
Pushed by smartins into branch '1.4'.

inefficient-qlist: Use 64 as the limit, instead of sizeof(void*)

Means that if you're programming in a 32-bit environment you should
write portable code and not pessimize for 64-bit platforms. If
your code will never run in 64-bit using QVector won't be a pessimization
anyway, it's a good default.

Also fixes the unit-test output being different in 32-bit.

M  +1    -1    docs/checks/README-inefficient-qlist-soft.md
M  +4    -1    docs/checks/README-inefficient-qlist.md
M  +3    -1    src/QtUtils.h
M  +3    -2    src/checks/inefficientqlistbase.cpp

https://commits.kde.org/clazy/9713a15f65424f06e45c78fc1bf1c2d2b27f4e36
Comment 2 eric.lemanissier 2018-12-03 09:10:14 UTC
This commit silences a totally valid warning on 32 bit platforms: QLists of objects between 32bits and 64bits. They truely are inefficient, so it is a pessimization, and they should be replaced by QVector. What is more, replacing these QList by QVector is not a pessimization on 64 bits, so I don't get your argument about portability.
I think the proper fix would be to change SmallType in the test code with 
struct SmallType {
    char a[sizeof(void*)];
};
Comment 3 Sergio Martins 2018-12-03 11:09:23 UTC
you're right, reading the commit again it doesn't make much sense now :)
Comment 4 Sergio Martins 2018-12-03 19:00:13 UTC
Git commit ad8e58e41537a9656b7924b5447fdb6e7bbad43e by Sergio Martins.
Committed on 03/12/2018 at 18:59.
Pushed by smartins into branch '1.4'.

inefficient-qlist: Fix unit-tests on 32-bit.

M  +1    -1    tests/inefficient-qlist-soft/main.cpp
M  +1    -1    tests/inefficient-qlist/main.cpp

https://commits.kde.org/clazy/ad8e58e41537a9656b7924b5447fdb6e7bbad43e