3 ms·
We are not talking about that actually.
by sylware 1y ago
We are not talking about that actually.
- pjmlp 1y agoActually we are, because that is one of the reasons why C++ should be used instead of C. Although ideally both should have been replaced by now.
- uecker 1y agoI would say that C++ pulls in so much entropy, that having standardized array and string types does not really make up for it. And the standardized arrays are not even safe in C++: https://godbolt.org/z/Y4f4v8M3z https://godbolt.org/z/Y4f4v8M3z
- pjmlp 1y agoBecause you ignored on purpose the at() method. https://godbolt.org/z/6PY1ve8ev https://godbolt.org/z/6PY1ve8ev Or to use one of the beloved compiler extensions, https://godbolt.org/z/6KKjcM7bP https://godbolt.org/z/6KKjcM7bP Additionally these extensions are now part of C++ as soon C++26 gets ratified, given that P3471R4 has been accepted. Whereas in C that isn't even an option.
- uecker 1y agoI haven't seen at() used a lot and simply using C++ and C would not make your programs magically use at() instead []. P3471 is not required to be supported by an implementation, and bounds checking extensions also exist for C.
- pjmlp 1y agoLikewise, I am yet to see such extensions for C being used in the wild, especially as they require extensions that no one is using unless their boss tells them so. However the big difference is that WG21, at least is making something about it. On C land, radio silence and worse, clever ideas like VLAs on the stack, naturally also without bounds checking.
- uecker 1y agoBounds sanitizer with trapping is used in the wild by important projects, e.g. the Linux kernel on various mobile devices. WG14 is also working on such topics, so this is more your ignorance speaking. But complaining on the internet about the work of volunteers is rather bad style anyway, IMHO. I am not sure what VLA on the stack have to do with it, but VLAs certainly enable bounds checking when used. The more important thing is the type system part.