[cfe-dev] Warning at always true condition

Devchandra L Meetei dlmeetei at gmail.com
Mon Jun 11 23:12:21 PDT 2012


Sorry but true.
This is not what, I was looking.

>char *p ="Hello World\n";
>if(p[0] != 'h' || p[0] != 'H')
>{
>    cout << "Word does not start with h/H\n";
>}

The condition is always true and none of compiler seems to warn them.


--Regards
--Deleisha



On Tue, Jun 12, 2012 at 11:30 AM, Devchandra L Meetei <dlmeetei at gmail.com>wrote:

> Thanks Sean
> I will have a look at that.
> Thanks for the pointer
>
> --Deleisha
>
>
> On Tue, Jun 12, 2012 at 5:34 AM, Seth Cantrell <bames53 at gmail.com> wrote:
>
>> There's a -Weverything which I think you can use to check to see if a bit
>> of code triggers any warnings.
>>
>> On Jun 11, 2012, at 7:10 AM, Devchandra L Meetei wrote:
>>
>> > Hi All
>> > Does clang support any switch to warn about a conditional eg in if(p*
>> !='h' || p* !='H'), which is always true.
>> >
>> >
>> > Thankss in reply for  timely response
>> >
>> > Warm Reagrds
>> > --Dev
>> > _______________________________________________
>> > cfe-dev mailing list
>> > cfe-dev at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120612/fd41ddf6/attachment.html>


More information about the cfe-dev mailing list