Re:Nginx C function
by abstractbeliefs on Sunday October 14, 2018 @02:05AM
(#18211592)
Well, there's a little more than that, as we actually have told compiler devs we don't want that.
When developers demand that compilers compete with each other on fractions of a percent of runtime performance, we set ourselves up for things like UB acting in unintuitive ways. When people give us the choice between safer but slower systems, and fast but unsafe ones, until recently people have overwhelmingly chosen fast and unsafe and pretended they're superhuman enough to not write bad code.
Re:Nginx C function
by anonymoushn on Sunday October 14, 2018 @02:54AM
(#18211717)
This is probably too much to ask for. I recently fixed an issue caused by UB in openresty of the form "nginx uses a NULL pointer and a length of 0 to signify a null string" + "nginx sometimes searches for strings in other strings using a function that takes start and end pointers for the haystack". This function works fine on lots of 0-length haystack strings (probably returning no match), but as you probably know, NULL + 0 is allowed to evaluate to anything. This seems pretty hard to detect statically short of banning programs that do arithmetic on any pointer without first NULL checking it.
I completely agree with you on all points. Languages exist to make our lives easier.