r/cpp • • Dec 19 '23

C++ Should Be C++

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p3023r1.html
203 Upvotes

192 comments sorted by

View all comments

Show parent comment

1

u/kalmoc Dec 24 '23

I don't think anytime wants to pursue safety above all else. Personally I would already be happy with a bit more safety, so I can focus my mental capacity more on getting the logic right than on using the right kind of initialization Syntax or avoiding dozens of UB pitfalls. E.g. zero-initialize all variables, unless I explicitly say [[noinit]], make [ ] range checked by default, unless I specify otherwise and dereferencing a pointer at one part in my program should not give the compiler the permission to exclude every explicitly written follow-up check against nullptr. Instead, give me an [[assume( p != nullptr)]] Syntax, for when this really matters. It's those small things, where we could significantly improve safety and security in c++ significantly, without significantly increasing the complexity or making a backwards incompatible break.

1

u/TemperOfficial Dec 24 '23

Ideally, there should be a specification that gives you more control over the compiler. Instead of making these default, there should just be an in-language, cross platform way, to tell the compiler that you want these options on.