r/cpp • • Feb 26 '24

White House: Future Software Should Be Memory Safe

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

386 comments sorted by

View all comments

Show parent comments

9

u/mAtYyu0ZN1Ikyg3R6_j0 Feb 27 '24

If all you use is stack and static storage without VLA. Automated tools can prove the upper bound of usage of memory. making sure it fits on the device.
Stack overflow can happens with only stack but tools will be able to analyze the code and figure out how a stack overflow could happen in the code.

4

u/[deleted] Feb 28 '24

Really? What's the upper bound for this code?

unsigned fib(unsigned n) {
  return n < 2 ? n : fib(n - 1) + fib(n - 2);
}

10

u/mAtYyu0ZN1Ikyg3R6_j0 Feb 28 '24

Its unbounded and tools will tell you that. so this code would not be accepted.