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


Groups > comp.lang.c > #22129

Re: Signed mod unsigned

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Signed mod unsigned
Date 2012-06-11 15:49 -0700
Organization None to speak of
Message-ID <lnfwa1a2h7.fsf@nuthaus.mib.org> (permalink)
References (6 earlier) <kfnr4tqgnwz.fsf@x-alumni2.alumni.caltech.edu> <jqsgu1$4so$1@news.albasani.net> <0.98a376f61e7465ca9f4c.20120608123059BST.877gvi9h1o.fsf@bsb.me.uk> <jr1nf9$t7f$1@news.albasani.net> <0.d1bca05c7631f9b50582.20120610144036BST.87fwa3xp2j.fsf@bsb.me.uk>

Show all headers | View raw


Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
> Johannes Bauer <dfnsonfsduifb@gmx.de> writes:
>> On 08.06.2012 13:30, Ben Bacarisse wrote:
>>> I don't want to make you feel bad again, but this last case is one of
>>> the oddest corners of C and can be quite safely ignored by almost
>>> everyone (indeed by everyone, soon, if C11 gets a hold).
>>
>> No worries, you haven't made me feel bad again :-)
>>
>> Much rather curious: In what ways does C11 change this behavior? I
>> haven't looked into C11 at all yet and am really interested what that
>> change could be (while still remaining backwards compatible).
>
> What's happened (thanks, Tim, for making me go look) is that the phrase
> "other than int or unsigned int" has been added to exclude them from the
> integer promotions.  This means that unsigned int is never promoted to
> int, even on those odd systems where the rule would otherwise apply ("if
> an int can represent all of the values of the original type [...] the
> value is converted to an int").
>
> This is not backwards compatible on those odd implementations, but since
> it seems the effect of the old rule on unsigned int was introduced
> inadvertently, the committee must have felt it worth breaking
> compatibility to tidy this up.

It's not backwards compatible with implementations where an int can old
all the values of unsigned int that followed the letter of the standard.

I rather doubt that there are any such implementations in the real
world.  My guess (and it's only a guess) is that there are very few
implementations with UINT_MAX == INT_MAX, and of those implementations
few if any fully conformed to C99.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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


Thread

Signed mod unsigned Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-06-06 15:55 +0200
  Re: Signed mod unsigned James Kuyper <jameskuyper@verizon.net> - 2012-06-06 10:41 -0400
    Re: Signed mod unsigned Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-06-07 12:12 +0200
      Re: Signed mod unsigned James Kuyper <jameskuyper@verizon.net> - 2012-06-07 06:44 -0400
        Re: Signed mod unsigned Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-06-07 13:31 +0200
  Re: Signed mod unsigned gwowen <gwowen@gmail.com> - 2012-06-06 07:53 -0700
    Re: Signed mod unsigned Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-06-07 12:15 +0200
      Re: Signed mod unsigned "BartC" <bc@freeuk.com> - 2012-06-07 12:29 +0100
        Re: Signed mod unsigned Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-06-07 13:43 +0200
        Re: Signed mod unsigned Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-07 07:46 -0400
          Re: Signed mod unsigned Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-07 20:58 +0100
            Re: Signed mod unsigned Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-07 19:58 -0400
            Re: Signed mod unsigned Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-08 02:20 -0700
              Re: Signed mod unsigned Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-06-08 11:33 +0200
                Re: Signed mod unsigned Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-08 12:30 +0100
                Re: Signed mod unsigned Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-08 11:12 -0700
                Re: Signed mod unsigned Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-08 20:37 +0100
                Re: Signed mod unsigned Keith Thompson <kst-u@mib.org> - 2012-06-08 13:44 -0700
                Re: Signed mod unsigned Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-08 22:22 +0100
                Re: Signed mod unsigned Johannes Bauer <dfnsonfsduifb@gmx.de> - 2012-06-10 10:56 +0200
                Re: Signed mod unsigned Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-10 14:40 +0100
                Re: Signed mod unsigned Keith Thompson <kst-u@mib.org> - 2012-06-11 15:49 -0700
                Re: Signed mod unsigned Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-24 09:32 -0700
                Re: Signed mod unsigned Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-08 11:05 -0700
              Re: Signed mod unsigned Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-08 12:06 +0100
                Re: Signed mod unsigned Tim Rentsch <txr@alumni.caltech.edu> - 2012-06-08 11:32 -0700
  Re: Signed mod unsigned Edward Rutherford <edward.p.rutherford79@REMOVETHIS.gmail.com> - 2012-06-06 22:15 +0000
    Re: Signed mod unsigned James Kuyper <jameskuyper@verizon.net> - 2012-06-06 18:29 -0400
      Re: Signed mod unsigned Edward Rutherford <edward.p.rutherford79@REMOVETHIS.gmail.com> - 2012-06-07 20:44 +0000
        Re: Signed mod unsigned James Kuyper <jameskuyper@verizon.net> - 2012-06-07 17:08 -0400

csiph-web