News for hackers. Stuff that matters.
Re:My Reaction to Dr. Stroustrup’s Recent Memory Safety Comm... by voxelghost on Thursday February 02, 2023 @09:39PM (#34636473)
I know there is no unsafe keyword, but I was suggesting one should be added.

I have decades-long experience with C++, but not all people do, and all people ,even experienced developers make mistakes or get lazy and take the easy way out from time to time.

I think one lesson C++ could take from rust, if nothing else, is that clearly demarking unsafe code sections is beneficial in and of itself.

If Strostrup makes the claim that developers using old C features is the main security problem of modern C++ , then an unsafe keyword would guide behavior towards safe usage.

    #No "old unsafe C" here

    UNSAFE{
    #Full C++, including "old unsafe C" here
      ...
    }

    #No "old unsafe C" here


    >c++                / treat code as "New Safe C++ only", except for UNSAFE sections
    >c++ --no-unsafe    / treat all code as "New safe C++ only"  UNSAFE not allowed
    >c++ --allow-unsafe / current behavior, allow all C++ including "old unsafe C" in all sections
Re:My Reaction to Dr. Stroustrup’s Recent Memory Safety Comm... by pjmlp on Friday February 03, 2023 @04:13AM (#34638995)
Microsoft is thinking down those lines given, see their "-memory-safe C++" talk at CppCon.

https://www.youtube.com/watch?v=ml4t-6bg9-M

However, this is only one compiler, not ISO C++.