public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: unsigned comparison warning
       [not found]   ` <489098BF.4070004@picochip.com>
@ 2008-07-30 22:07     ` Manuel López-Ibáñez
  2008-09-23 13:06       ` Hariharan Sandanagobalane
  0 siblings, 1 reply; 3+ messages in thread
From: Manuel López-Ibáñez @ 2008-07-30 22:07 UTC (permalink / raw)
  To: Hariharan; +Cc: Ian Lance Taylor, gcc-help

2008/7/30 Hariharan <hariharans@picochip.com>:
> Thanks Ian. I will raise this in gcc-help mailing list.

GCC versions previous to 4.3 were inconsistent. This was fixed in GCC
4.3 by grouping all similar warnings under -Wtype-limits which is
enabled by -Wextra.

See http://gcc.gnu.org/gcc-4.3/changes.html

Cheers,

Manuel.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: unsigned comparison warning
  2008-07-30 22:07     ` unsigned comparison warning Manuel López-Ibáñez
@ 2008-09-23 13:06       ` Hariharan Sandanagobalane
  0 siblings, 0 replies; 3+ messages in thread
From: Hariharan Sandanagobalane @ 2008-09-23 13:06 UTC (permalink / raw)
  To: Manuel López-Ibáñez; +Cc: gcc-help

Thanks Manuel. I personally feel that this warning should be a part of 
-Wall.

Cheers
Hari

Manuel López-Ibáñez wrote:
> 2008/7/30 Hariharan <hariharans@picochip.com>:
>> Thanks Ian. I will raise this in gcc-help mailing list.
> 
> GCC versions previous to 4.3 were inconsistent. This was fixed in GCC
> 4.3 by grouping all similar warnings under -Wtype-limits which is
> enabled by -Wextra.
> 
> See http://gcc.gnu.org/gcc-4.3/changes.html
> 
> Cheers,
> 
> Manuel.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* unsigned comparison warning
@ 2008-07-30 19:18 Hariharan
  0 siblings, 0 replies; 3+ messages in thread
From: Hariharan @ 2008-07-30 19:18 UTC (permalink / raw)
  To: gcc-help, Hariharan Sandanagobalane

Hello,
I found something rather strange with the unsigned comparison warnings 
in GCC.

If i had,

unsigned char a; 
 

 

int foo () 
 

{ 
 

  if (a >= 0) 
 

    return 0; 
 

  else 
 

    return 1; 
 

}

and i did gcc -O2 -c trial.c, then i get a warning

trial.c:6: warning: comparison is always true due to limited range of 
data type

It works the same way if i used an unsigned short. But, if i use 
unsigned int/long, i dont get this warning. This is on x86. Is there an 
explanation for this?

I had initially tried this with 4.1.1 (default on RHE5), but Ian 
mentioned that the behaviour is the same on mainline with -Wextra.

Cheers
Hari








^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-09-23 13:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <488EE8E4.4050309@picochip.com>
     [not found] ` <m33als4w7k.fsf@google.com>
     [not found]   ` <489098BF.4070004@picochip.com>
2008-07-30 22:07     ` unsigned comparison warning Manuel López-Ibáñez
2008-09-23 13:06       ` Hariharan Sandanagobalane
2008-07-30 19:18 Hariharan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).