[PATCH] Fix 'array subscript is above array bounds' warning in res_send.c

Paul Eggert eggert@cs.ucla.edu
Tue Dec 16 18:42:00 GMT 2014


On 12/16/2014 10:05 AM, Roland McGrath wrote:
> changing the source code just to make the compiler happy is not the thing
> we avoid: it's changes that de-optimize the generated code.

For what it's worth, we use a similar rule in Gnulib and core GNU apps.

That being said, I can't resist mentioning that Dijkstra was a fan using 
the 'i == n' test as opposed to the 'i >= n' test in cases like these, 
so I expect he would not have favored this change. Dijkstra's argument 
was that if 'i == n' is correct, then using 'i >= n' will make the code 
more robust in the presence of programming errors elsewhere, which is 
not what you should want: you should want your program to crash nicely 
(not limp along) in the presence of these other errors.  Those were the 
days, eh?



More information about the Libc-alpha mailing list