Re:Out-of-bounds read and write in the glibc's qsort()
by n_plus_1_acc on Monday February 05, 2024 @04:48PM
(#39267704)
I consider the use of undefined behaviour in trivially detectible cases like this a great mistake. Sure, undefined behaviour is useful for many Compiler optimizations, but requiring qsort implementations to not do out-of-bounds reads does not hurt.
[ Parent
| on HN ]
Re:Out-of-bounds read and write in the glibc's qsort()
by mjevans on Monday February 05, 2024 @05:05PM
(#39267894)
IMO Optimizations like that should be at least a __warning__ and ideally lead to refactored and more correct code as a result.
Also IMO, the default should always be unsigned (modulus) integers, not signed. That would promote more correct consideration of integer types and operations. Yes, the ship has sailed on that, but it would also be nice if code linters added 'signed ' where not specified to remind everyone of the present default.