[Interest] Klocwork errors in Qt

Roland Hughes roland at logikalsolutions.com
Wed Dec 4 15:31:13 CET 2019


On 12/4/19 5:00 AM, Thiago Macieira wrote:
> On Tuesday, 3 December 2019 17:36:37 PST Christian Gagneraud wrote:
>> My point is that this sort of bugs are really hard to detect during
>> code review. This is subtle & nasty 'feature' of QStringBuilder (a
>> choice in its implementation).
> Understood, but it shows up quickly when running the code or, at worst,
> Valgrind or ASan time.
>
> It hasn't affected us in Qt itself because we use the Almost Never Auto coding
> style.
>
That style is also required in any shop using actual software 
engineering, particularly in the medical device world.

Auto should have never been added to the language. It was an attempt to 
"dumb down" the skill level, thus lowering the bar for new developers.

A shortcut is the longest distance between any two points, you just may 
not realize it at the time you take it.

It won't be that much longer before auto ends up on the trash heap with 
digraphs and trigraphs.

https://en.wikipedia.org/wiki/Digraphs_and_trigraphs

IBM at least had a legitimate reason for fighting that fight. EBCDIC 
didn't have the characters and neither did the keyboards.

https://www.oreilly.com/library/view/signalr-real-time-application/9781782164241/graphics/4241OS_01_01.jpg

If you think auto won't be removed as a failed experiment, how about 
"new"? Deprecated in C++20 and slated for removal in C++23.

https://www.modernescpp.com/index.php/no-new-new

std::auto_ptr was deprecated in C++11 and removed in C++17.

Smart pointers have had more than their fair share of growing pains. Had 
to be ripped out of the last project I was on. They just weren't as 
smart as the name implies. Most likely they will go away with "new."

https://www.fluentcpp.com/2018/04/01/cpp-will-no-longer-have-pointers/

The chasm between C and C++ will then be more than an ocean wide. C++ 
and by extension Qt, won't be usable when you have hardware which must 
be addressed via addresses and memory mapping, or so it would seem.

Some more reading on the removal of pointers

https://www.fluentcpp.com/2018/04/01/cpp-will-no-longer-have-pointers/

Removal of new and pointers is really going to hose .UI files and 
however many thousand examples like this

https://riptutorial.com/qt/example/20811/setting-a-ui-widget-s-stylesheet

are floating around. Not to mention QWidget *parent parameters used 
everywhere like the Analog Clock Example.

https://doc.qt.io/qt-5/qtwidgets-widgets-analogclock-example.html

QML and basically any other scripting/interpreted language is unusable 
where human life is potentially at risk, i.e. Medical devices, crane 
control systems. I'm sure others can list more.

-- 
Roland Hughes, President
Logikal Solutions
(630)-205-1593

http://www.theminimumyouneedtoknow.com
http://www.infiniteexposure.net
http://www.johnsmith-book.com
http://www.logikalblog.com
http://www.interestingauthors.com/blog



More information about the Interest mailing list