This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: gcc-current: badly worded warning?


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


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