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: No Compilation Warning...


----- Original Message -----
From: llewelly@xmission.com
Date: 14 Jun 2004 10:37:28 -0600
To: "Manje Gowda S G" <sakala@linuxmail.org>
Subject: Re: No Compilation Warning...

> "Manje Gowda S G" <sakala@linuxmail.org> writes:
> 
> > Hi,
> >  
> > test.c: In function `main':
> > test.c:7: warning: comparison is always true due to limited range of data type
> >  
> > I am getting the above warning on compilation of the following code 
> >  
> > #include <stdio.h>
> >  
> > int main()
> > {
> >         unsigned short s;
> >  
> >         if (0 <= s) {
> >                 printf("Hello Sakala\n");
> >         }
> >         return(0);
> > }
> >  
> > Ya, warning make sense but if I change "unsigned short s;" to as follows
> >  
> > #include <stdio.h>
> >  
> > int main()
> > {
> >         unsigned int s;
> >  
> >         if (0 <= s) {
> >                 printf("Hello Sakala\n");
> >         }
> >         return(0);
> > }
> >  
> > then on compilation, (if I am not wrong...) I am suppose to get the same warning message, but no.
> > Is this a bug or am I wrong some where? sorry if I am wrong.
> >  
> > I use...,
> > gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
> 
>
> I get:
> gowda.cc: In function nt main()':
> gowda.cc:7: warning: comparison of unsigned expression >= 0 is always true
> 
> for gcc 2.95.3, 3.3.3, 3.4, and 3.5 20040606 .
> 
> Maybe the bug is unique to 3.3.2 or the redhat derivative. 
> 

Do you get the warning for "unsigned int s" declaration?
I feel Both the messages sounds same
What is bothering me is, no warning Message if it is declared as "unsigned int s" in the program???.

I have checked for the same with the following versions of GCC, still it is the same problem

1) gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)
2) gcc version 2.95.3 20010125 (prerelease, propolice)
3) gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)

Even compiling with optimization flag will not flash the warning message.

Best Regards,
-Manje Gowda
-- 
______________________________________________
Check out the latest SMS services @ http://www.linuxmail.org 
This allows you to send and receive SMS through your mailbox.


Powered by Outblaze


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