This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]