delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/12/26/02:46:34

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Date: Wed, 26 Dec 2001 09:44:29 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: djgpp-workers AT delorie DOT com
Message-Id: <7458-Wed26Dec2001094429+0200-eliz@is.elta.co.il>
X-Mailer: emacs 21.1.50 (via feedmail 8 I) and Blat ver 1.8.9
In-reply-to: <200112251716.SAA11347@father.ludd.luth.se> (message from Martin
Str|mberg on Tue, 25 Dec 2001 18:16:39 +0100 (MET))
Subject: Re: gcc 3.03 and libc sources
References: <200112251716 DOT SAA11347 AT father DOT ludd DOT luth DOT se>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: Martin Str|mberg <ams AT ludd DOT luth DOT se>
> Date: Tue, 25 Dec 2001 18:16:39 +0100 (MET)
> 
> > I still have no idea why does gcc complain here.  What's wrong about 
> > having an expression whose result could be either signed or unsigned?  I 
> > think it's worth a bug report nonetheless, if only to hear an 
> > explanation from the maintainers.
> 
> I'm using -Wsign-compare, which is the option that produces this
> warning. I assume this makes gcc complain about implicit casting. So
> if we have a "bool ? signed : unsigned" expression, one of signed or
> unsigned must be casted.

That's not what -Wsign-compare is supposed to be about.  It supposed
to warn about the following code:

   int foo;
   unsigned bar;

   if (foo > bar)
     do_something ();

This kind of code has a subtle bug: if foo is negative, you might
have do_something() called, even though a negative value cannot
possibly be larger than an unsigned value!  Thus the ``compare'' in
``-Wsign-compare''.  This warning helps you find bugs that can lurk
for years without being discovered.

But what GCC flags in the cases you mentioned is something very
different: there's no comparison between signed and unsigned values in
those cases.  What we have is an expression that sometimes yields
signed values and sometimes unsigned values.  What's wrong with that?

So I maintain that a bug report should be sent to the GCC list.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019