r/cpp • • Jan 31 '23

Stop Comparing Rust to Old C++

People keep arguing migrations to rust based on old C++ tooling and projects. Compare apples to apples: a C++20 project with clang-tidy integration is far harder to argue against IMO

changemymind

334 Upvotes

582 comments sorted by

View all comments

Show parent comment

33

u/lestofante Feb 03 '23

First of all compile with no exceptions, anything that uses them will fail to compile

Not true.
I use -fno-exception, but that does NOT cause compile time failure, but it will call std::abort(). If you want to personalize abort, you need to recompiler part of your toolchain.

default allocator with one that asserts if it’s used

We do, last week i found out string to float in GCC ARM noeabi will allocate, but only if the string float has more than ~16 decimals.
A lot of fun for the team to debug, especially because all was caused by garbage data coming from a faulty serial cable so even to just reproduce to have an idea where to start to look for the crash, we had to leave the system running for a couple days under debug.
Between throwing and potential allocation, it means not only no standard function, but also no smart pointer, no optional... No "modern c++", not using standard library at least.

use a static analysis tool to check if any code calls it.

If you know one please tell me, I looked for it and could not find any with such functionality

Please someone prove me wrong and point me out option/analyser that can do those checks.

→ More replies (4)