4 ms·
Thanks for the detailed answer. There is another thing I found string able to do: throw std::length_error. But that's consistent with your statement that it ei
by jeffbee 4y ago
Thanks for the detailed answer.
There is another thing I found string able to do: throw std::length_error. But that's consistent with your statement that it either succeeds or throws.
So, going back to my question, it seems like the small leap from C to C++, if the author embraces the STL, does categorically prevent this class of overflow.
- LegionMammal978 4y ago> So, going back to my question, it seems like the small leap from C to C++, if the author embraces the STL, does categorically prevent this class of overflow. "Categorically" is a bit strong; if any index were ever truncated to a 32-bit integer before writing to s[i], that could also cause major issues. Also, the C++ standard library does not have a monopoly on safe interfaces; all of the relevant APIs can be trivially reimplemented in C. It's just that C libraries have not historically made safe internal interfaces a priority.