Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Fred K <fred.l.kleinschmidt@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: (un)signed warning |
| Date | 2012-04-26 11:19 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <15395227.5.1335464381460.JavaMail.geo-discussion-forums@pbcgx8> (permalink) |
| References | <jnb3rm$kcn$1@ccpntc8.in2p3.fr> <jnb939$b32$1@dont-email.me> <jnbn1t$73g$1@ccpntc8.in2p3.fr> <13669218.840.1335458136446.JavaMail.geo-discussion-forums@ynej8> |
On Thursday, April 26, 2012 9:35:36 AM UTC-7, Malcolm McLean wrote:
> בתאריך יום חמישי, 26 באפריל 2012 15:45:16 UTC+1, מאת Guillaume Dargaud:
> >
> > int n, RL;
> >
> > n=RL=GpsResponseLength()-4;
> > n+=4;
> >
> > else if (n<RL) printf("Reply too short");
> >
> n must always be larget than RL, unless an arithemtic overflow occurs. Since n and Rl are signed, this generates undefined behaviour (the program could crash out with an arithemtic overflow message, or it could set N to a very high negative number, or, as in this case, it could simply optimise out the comparison to RL and assume that n is bigger than it). The compiler is warning you that it has taken the last option, which might not be what you want, since the redundant test might well be a erroneous test for overflow. It can't read your mind.
> --
> Read my website. Lots of C programming resources.
> http://www.malcommclean.site11.com/www
What C programming resources? That site seems to be an ad for "free" web hosting.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
(un)signed warning Guillaume Dargaud <use_the_contact_form@www.gdargaud.net> - 2012-04-26 11:17 +0200
Re: (un)signed warning James Kuyper <jameskuyper@verizon.net> - 2012-04-26 06:47 -0400
Re: (un)signed warning Guillaume Dargaud <use_the_contact_form@www.gdargaud.net> - 2012-04-26 16:45 +0200
Re: (un)signed warning James Kuyper <jameskuyper@verizon.net> - 2012-04-26 11:39 -0400
Re: (un)signed warning Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-04-26 09:35 -0700
Re: (un)signed warning Fred K <fred.l.kleinschmidt@gmail.com> - 2012-04-26 11:19 -0700
Re: (un)signed warning ImpalerCore <jadill33@gmail.com> - 2012-04-26 12:01 -0700
Re: (un)signed warning Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-04-28 04:23 -0700
csiph-web