This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc-current: badly worded warning?
- From: Eyal Lebedinsky <eyal at eyal dot emu dot id dot au>
- To: list gcc <gcc at gcc dot gnu dot org>
- Date: Sun, 03 Jun 2007 14:51:05 +1000
- Subject: Re: gcc-current: badly worded warning?
- References: <4652F1DE.2050407@eyal.emu.id.au> <1180510880.28792.4.camel@localhost>
Already done
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32061
I should make it clear that I am also interested in a warning for the
purpose of indicating that something 'has no effect', which is the case in
expr && non-zero-const
expr || zero-const
and not just the case where the result is 'always true/false' which is
the subject of the PR
expr && zero-const
expr || non-zero-const
And yes, if the const is first then it can cause the second expression to
never be evaluated which may be an issue when side-effects are present.
I give this example of why I want to see such warnings
if (day_of_week == DOW_SUNDAY || DOW_MONDAY)
and I know that often a similar construct is intentional, like
if (report_mode == REPORT_ACTIVE || DEBUG_FORCE_REPORT)
cheers
Ben Elliston wrote:
> Hey Eyal,
>
>
>>I see two kinds of warnings:
>> warning: logical '||' with non-zero constant will always evaluate as true
>> warning: logical '&&' with non-zero constant will always evaluate as true
>>
>>The first statement is true, the second false.
>
>
> You're right. Can you please file a PR for this?
>
> Thanks,
> Ben
>
>
--
Eyal Lebedinsky (eyal@eyal.emu.id.au) <http://samba.org/eyal/>
attach .zip as .dat