public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Relaxing -Wsign-compare
@ 2001-09-20  8:45 Morten Welinder
  2001-09-20 11:43 ` Neil Booth
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Morten Welinder @ 2001-09-20  8:45 UTC (permalink / raw)
  To: gcc

IMHO, the -Wsign-compare is a bit too agressive to be really useful.
Consider this example:

-----------------------------------------------------------------------------
struct {
  int a, b;
} foo [] = {
  {1,2}, {3,4}
};

int
main (int argc, char **argv)
{
  int i;

  for (i = 0; i < sizeof (foo) / sizeof (foo[0]); i++)
    ;

  return 0;
}
-----------------------------------------------------------------------------


> gcc-3.0 -Wsign-compare signed.c
signed.c: In function `main':
signed.c:12: warning: comparison between signed and unsigned

A similar warning can be had with typical MIN and MAX macros when
used with an unsigned expression and an explicit integer, say
MAX (expr, 42).

Would it be reasonable to silence this warning when one of the sides is
a constant (in the C meaning) that fits well within the range of the
other side's type?

Morten

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2001-09-23 15:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-20  8:45 Relaxing -Wsign-compare Morten Welinder
2001-09-20 11:43 ` Neil Booth
2001-09-20 12:03   ` Morten Welinder
2001-09-20 16:37   ` Richard Henderson
2001-09-20 12:11 ` Frank Klemm
2001-09-21  2:46   ` Gabriel Paubert
2001-09-20 16:34 ` Richard Henderson
2001-09-21 10:48   ` Morten Welinder
2001-09-21 11:07     ` Richard Henderson
2001-09-21 14:47       ` Fergus Henderson
2001-09-23 15:30     ` Frank Klemm
2001-09-21 14:54   ` Fergus Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).