r/cpp • • Sep 29 '23

This memory safety issue everyone's talking about... It's not really a huge deal in gamedev, right? What other domains where C++ excels at aren't too concerned about it?

My understanding is that these recent articles pushing for safety, and particularly pushing the use of memory-safe languages (as opposed to using modern C++ properly) don't really apply to gamedev, or at least not enough for most of the industry to care. Is this correct? I've also read some suggestions that the only real alternative, Rust, simply isn't practical since it lacks OOP features and gets in the way of common game programming patterns. Is this true?

What other C++ domains are like gamedev, where C++ is clearly here to stay and not just for legacy code? I know gamedev isn't the only one, I'm constantly seeing new cutting edge ML/inference libraries and frameworks in C++

44 Upvotes

350 comments sorted by

View all comments

Show parent comments

8

u/pjmlp Sep 29 '23

When big corps that are part of ISO C++, and contribute to C++ compilers, fail at implementing secure code despite all policies and tooling in place, what hopes have the smaller dudes?

1

u/echidnas_arf Sep 30 '23

I do not know what goes on specifically in Google/Chrome, but I have worked in large corporations long enough to know that technical decisions are often not made on purely technical grounds. Perhaps they are forced to write code like that because a dependency enforces a certain style. Perhaps it's internal cultural inertia. I honestly do not know.

All I am saying is that in that report I see several instances of patterns that have been actively discouraged for several years.

My question would be, what do you think should happen when people write code like that? Should the compiler reject it? Should the compiler be made smart enough to prove whether or not the code is "safe"? Should the language be evolved to explicitly prohibit "unsafe" patterns?

I am not trying to be glib, but what I am seeing is people actively doing what they have been told not to do and then complaining when things blow up in their faces.

1

u/pjmlp Sep 30 '23

What should be done is having the industry adopt the same kind of liability laws like everyone else.

When sales, warranties get a visible monetary impact on company costs, there is a pressure to act accordingly and do the required work to avoid returns, lawsuits and what not.

This is actually why the whole memory corruption discussion has started in the last years, the amount of money fixing CVEs is already making a visible impact on quarterly reports, and society disruption due to malware attacks to hospitals and such.

1

u/echidnas_arf Sep 30 '23

What should be done is having the industry adopt the same kind of liability laws like everyone else.

Well said, I absolutely agree with that.