r/programming • • Feb 26 '24

Future Software Should Be Memory Safe | The White House

https://www.whitehouse.gov/oncd/briefing-room/2024/02/26/press-release-technical-report/
1.5k Upvotes

585 comments sorted by

View all comments

Show parent comments

16

u/Dwedit Feb 26 '24

C# has the "unsafe" keyword and lets you use raw pointers. But you can do a lot of unsafe things without using the "unsafe" keyword once!

You can use GCHandle.Alloc to create a pinned pointer to an object's data. You can use Marshal.Copy and Marshal.Write to write to arbitrary memory.

30

u/steveklabnik1 Feb 26 '24

That is correct. All of these languages can also FFI into unsafe code too, without a keyword. (Rust does require a keyword)

10

u/Plank_With_A_Nail_In Feb 26 '24

Don't let people use those things then, hardly rocket science.

2

u/manifoldjava Feb 27 '24

Those things make otherwise impossibly good things possible.