Serious code generation/optimisation bug (I think)
Ian Lance Taylor
iant@google.com
Tue Jan 27 21:11:00 GMT 2009
Daniel Jacobowitz <drow@false.org> writes:
> On Tue, Jan 27, 2009 at 06:52:18PM +1100, zoltan@bendor.com.au wrote:
>> // Debug( tst->value );
>>
>> if ( ! tst ) {
>> ptr->next = (void *) 0;
>> break;
>> }
>
> This optimization comes up on the list frequently. Do folks think a
> corresponding warning would be a win? "warning: ignored NULL check
> because pointer has already been dereferenced"?
While such a warning sounds fine to me, I'm not sure that it should be
on by default. By default I think it will trigger on plenty of
perfectly reasonable code, such as sequences of inline functions or
macros where each function/macro checks for NULL. If it's not on by
default, I'm not sure how much help it will be.
Also, of course, this would turn out to be another middle-end warning,
and some people get antsy about those. Though it wouldn't be as bad
as some.
Ian
More information about the Gcc
mailing list