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


Groups > comp.lang.c > #19965

Re: (un)signed warning

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

Show all headers | View raw


On 04/26/2012 10:45 AM, Guillaume Dargaud wrote:
>> 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.
> 
> Sorry about that.

I've given out essentially the same advice to many different people over
the years; I can't remember the last time anyone actually followed it.
Thank you for making me feel like someone was actually listening.

> I understood the issue when simplifying the code:

In my experience, that is very commonly the case.

...
> n=RL=GpsResponseLength()-4;
> n+=4;

That is VERY different from what you wrote in your original message:

> n = read(fd, Str, GPS_MAX_LEN);

I can see the reason for the warning in this version of the code. I'm
curious about what your original code looked like, that would cause you
to summarize it the way that you did in your first message, yet still
generated this warning message? I think it must have been a very poor
summary.

...
> else if (n<RL) printf("Reply too short");
...

> TestWarn.c:20:10: warning: assuming signed overflow does not occur when 
> assuming that (X - c) > X is always false [-Wstrict-overflow]
> 
> But no warning in -O1 or -O0

When you set the optimization level for gcc high enough, it performs
certain analyses of the code in support of those optimizations, and it
gives you warnings about some things it finds during that analysis that
it doesn't even notice at lower optimization levels.

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