Bjarne Stroustrup’s Plan for Bringing Safety to C++ (The New Stack)
Bjarne Stroustrup’s Plan for Bringing Safety to C++ (The New Stack)
Posted Nov 2, 2023 17:29 UTC (Thu) by adobriyan (subscriber, #30858)In reply to: Bjarne Stroustrup’s Plan for Bringing Safety to C++ (The New Stack) by ojeda
Parent article: Bjarne Stroustrup’s Plan for Bringing Safety to C++ (The New Stack)
"may contain" doesn't mean "contains". This fixation on UB is partially misguided.
> That is why they are "unsafe" in Rust terms, and why the statement about `wc -l` is quite close to reality.
C/C++ static checkers/compilers don't require to mark code with "safe" or "unsafe" and don't mark code themselves ex post facto.
Rustc requires unsafe marks thus creating the illusion that close to 100% of C/C++ code is unsafe.
I'm writing toy C compiler at the moment:
* C expressions are allocated from stable container,
* expressions form AST with pointers pointing to other expressions,
* pointers to expressions are never freed,
* references and other form of pointers aren't used,
* stable container is globally destructed when program exists (which is waste of cycles but this is for later).
It is easy to verify for a human at high level (and sanitizers confirm) that there are no leaks and
there are no bugs with pointer management despite having a awful lots of pointers.
Posted Nov 2, 2023 17:42 UTC (Thu)
by mb (subscriber, #50428)
[Link]
Yep. And that is what Rust calls "unsafe code, manually checked".
Get it now?
Bjarne Stroustrup’s Plan for Bringing Safety to C++ (The New Stack)
>there are no bugs with pointer management despite having a awful lots of pointers.
Safe code would be, if the compiler itself could prove that without human intervention.