Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #19952

Re: (un)signed warning

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: (un)signed warning
Date 2012-04-26 06:47 -0400
Organization A noiseless patient Spider
Message-ID <jnb939$b32$1@dont-email.me> (permalink)
References <jnb3rm$kcn$1@ccpntc8.in2p3.fr>

Show all headers | View raw


On 04/26/2012 05:17 AM, Guillaume Dargaud wrote:
> Hello all,
> can someone please explain this warning to me:
> 
> #define GPS_MAX_LEN 300
> unsigned char Str[GPS_MAX_LEN]="@@";
> int n, RL;
> 
> RL=SomeValue();
> n = read(fd, Str, GPS_MAX_LEN);
> if (n>=GPS_MAX_LEN)  printf(...);
> else if (n<0)	printf(...);
> else if (n==0) printf(...);
> else if (n<RL) printf(...);
> else if (Str[0]!='@' or Str[1]!='@') printf(...);
> else printf(...);
> 
> The line (n<RL) gives me the following warning:
> warning: assuming signed overflow does not occur when assuming that (X - c) 
>> X is always false [-Wstrict-overflow]

I filled in the details of your code to the minimal extent needed to
produce a compilable file, using -fstrict-overflow and
-Wstrict-overflow=4, without duplicating your warning message. This
means that something that you didn't tell us is responsible for that
message.

Please create a version of your code that has been modified to be as
small and simple as possible, while still demonstrating the problem.
Confirm that it still demonstrates the problem! Then cut and paste the
full exact text of your source code into the next message you send us.
Also cut-and-paste the exact command line that you used to compile the
code, and the full output of compiler when you issued that command.
Don't re-type anything - retyping often introduces errors that are
different from the ones that you were asking about.
-- 
James Kuyper

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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