Hacker News new | ask | show | jobs
by carbotaniuman 577 days ago
I've used vendor-specific C++ compilers with no bounds checking and a barely conforming stdlib, so by your logic C++ has zero bounds checking... Defaults matter!
1 comments

> I've used vendor-specific C++ compilers with no bounds checking and a barely conforming stdlib, so by your logic C++ has zero bounds checking...

I literally said exactly that: "The standard doesn't require any checks to begin with."

> Defaults matter!

Sigh... nobody claimed otherwise. You're really missing the point of the thread.

All I did was give people a tip on how to improve their code security. The exact sentence I wrote was:

>> "If you want bounds checking in your own code, start replacing T* with std::span<T> or std::span<T>::iterator whenever the target is an array."

"BUT DEFAULTS MATTER!!!", you rebut! Well OK, then I guess keep your raw pointers in and don't migrate your code? Sorry I tried to help!

Cool, let me know how to improve the code security on my vendor compiler then, I'll be waiting.
> Cool, let me know how to improve the code security on my vendor compiler then, I'll be waiting.

Switch to std::span and add 1 line to std::span::operator[] to check your bounds...

I don't think std::span is bounds checked. Try again.
> I don't think std::span is bounds checked. Try again.

That's why I said add 1 line to std::span::operator[] to check your bounds.

I'm telling you to modify the STL header. It's a text file. Add 1 line to make it bounds-checked.