This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix 'array subscript is above array bounds' warning in res_send.c
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>, libc-alpha at sourceware dot org, schwab at suse dot de
- Date: Tue, 16 Dec 2014 10:05:36 -0800 (PST)
- Subject: Re: [PATCH] Fix 'array subscript is above array bounds' warning in res_send.c
- Authentication-results: sourceware.org; auth=none
- References: <20141216100950 dot GM30928 at spoyarek dot pnq dot redhat dot com> <mvm388fkifz dot fsf at hawking dot suse dot de> <20141216104514 dot GN30928 at spoyarek dot pnq dot redhat dot com> <mvmy4q7j20b dot fsf at hawking dot suse dot de> <20141216112624 dot GO30928 at spoyarek dot pnq dot redhat dot com> <5490254E dot 8060508 at linux dot vnet dot ibm dot com> <20141216125211 dot GW30928 at spoyarek dot pnq dot redhat dot com> <54902C9E dot 5030408 at linux dot vnet dot ibm dot com> <20141216130524 dot GX30928 at spoyarek dot pnq dot redhat dot com> <54902FB8 dot 8070006 at linux dot vnet dot ibm dot com> <20141216134432 dot GY30928 at spoyarek dot pnq dot redhat dot com>
When changing the source code does not actually cause any de-optimization
of the generated code, then it seems cleaner to change the code rather than
to suppress the warning. In this case, changing the condition will change
what conditional-branch instruction is emitted, but it won't change the
number (or size) of instructions emitted or change anything that would
affect performance. It doesn't matter a lot either way. When the compiler
is being really dumb as appears to be the case here, then a substantial
comment about the compiler's stupidity is warranted; that makes it be even
less of a difference in cognitive load and source clutter between the code
change and the warning suppression. But as to the general rule/policy,
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.