public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Morten Welinder <terra@diku.dk>
To: neil@daikokuya.demon.co.uk
Cc: gcc@gcc.gnu.org
Subject: Re: Relaxing -Wsign-compare
Date: Thu, 20 Sep 2001 12:03:00 -0000	[thread overview]
Message-ID: <20010920190330.29288.qmail@ntyr.diku.dk> (raw)
In-Reply-To: <20010920194144.B3669@daikokuya.demon.co.uk>

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

[...]


   I don't think you've chosen a good example -- I'd claim that i should
   be an unsigned int.  Personally, it bugs me that people default to
   loops with int, when 95% of the time they're looping with unsigned
   quantities.

It ought not matter whether the type was "int" or "unsigned int".  In
both cases, the compiler ought to infer that the value will fit in
either type.  Then it can pick whatever instruction sequence it feels
like.  Ah, all the things one could do with infinite time and money...

   It can even give you better code to be looping unsigned,
   since some arithmetic operations can be more efficiently encoded if
   the compiler knows they are on unsigned quantities.

Or the other way around, perhaps.

   I think Kaveh has done some work on the compiler to improve this area
   in 3.1.

Great, thanks!

Morten

  reply	other threads:[~2001-09-20 12:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-20  8:45 Morten Welinder
2001-09-20 11:43 ` Neil Booth
2001-09-20 12:03   ` Morten Welinder [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010920190330.29288.qmail@ntyr.diku.dk \
    --to=terra@diku.dk \
    --cc=gcc@gcc.gnu.org \
    --cc=neil@daikokuya.demon.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).