3 ms·
> Not at all, because it doesn't fix out of bounds errors caused by copy-paste errors where the given buffer size doesn't match the actual size of the declared
by rurban 8y ago
> Not at all, because it doesn't fix out of bounds errors caused by copy-paste errors where the given buffer size doesn't match the actual size of the declared buffer or string.
That's wrong, check the implementation.
C++ only has advantages because there g++ is not as broken as gcc with constexpr, but clang since 5.0 is doing fine.
https://github.com/rurban/safeclib https://github.com/rurban/safeclib
- pjmlp 8y agoAs you mention on "Compile-time constraints" this extensions to Annex K require a supporting compiler. It is perfectly viable to have a 100% ISO C99/C11 compliant compiler that will happily overwrite the target buffer, read more bytes than actually exist or search the whole memory block for a '\0' terminator, because Annex K does not require the existence of the compiler extensions used by your safeclib.
- rurban 8y agoRight. Microsoft does it wrong. But neither ISP nor POSIX require _FORTIFY_SOURCE neither which uses the same object_size (bos) CHECKS. The alloc_size builtin or the CPU supported bounds checks are not used at all with the major libc's. Problem is not the Annex K, but the refusal to implement and use it. There's no problem with state as in errno or locale. The criticism is easily debunkable. It's outright NIH bias.
- pjmlp 8y agoWhat I would like to see would be tagged memory like the SPARC has, which was put to good effect on Solaris, to become common across all major platforms. Apparently at least Android might adopt it on ARM. And do concede, maybe the extensions you have used, to actually become part of Annex K as well instead of deprecating it. Because despite my dislike for C, I am fully aware that UNIX derived platforms will stay with us for the years to come, so we need to improve the current state of affairs somehow.