19 ms·
So _FORTIFY_SOURCE adds checks to functions like memcpy(), but seems to do nothing to help custom code that uses for loops and array indexing. I guess I'll kee
by nayuki 5y ago
So _FORTIFY_SOURCE adds checks to functions like memcpy(), but seems to do nothing to help custom code that uses for loops and array indexing.
I guess I'll keep using -fsanitize=address (ASan) in my debug builds.
- fwsgonzo 5y agoSome of those clever loops end up calling memcpy anyway because the compiler deems it to be faster, but yes. For better safety there needs to be bounds checking.
- dundarious 5y agoClang, and I believe gcc and many other compilers, can synthesize a memcpy from simple loops. I don't say this to vouch for its abilities, and in general I don't recommend relying on such transformations, but it will help probably for a non-trivial amount of such custom code -- but of course, nowhere near all.