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


Groups > comp.lang.c > #152483

Re: longer 'char literals' meaning in c

From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.lang.c
Subject Re: longer 'char literals' meaning in c
Date 2020-05-26 07:02 -0700
Organization A noiseless patient Spider
Message-ID <86367mu74p.fsf@linuxsc.com> (permalink)
References (9 earlier) <87d07i0y4r.fsf@nosuchdomain.example.com> <r8t7m9$8o1$1@z-news.wcss.wroc.pl> <878si5225f.fsf@nosuchdomain.example.com> <r8v1a3$b86$1@z-news.wcss.wroc.pl> <87lfm4ztok.fsf@nosuchdomain.example.com>

Show all headers | View raw


Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> antispam@math.uni.wroc.pl writes:
> [...]
>
>> You snipped the relevant context here.  The point is not about
>> INT_MIN macro, go back few posts to place where I wrote
>> original text, we (at least I am) discussing mulitcharacter
>> char constants and in particular values that implementation
>> may assign to them.  If that plus explanations added in following
>> posts is not enough, then I gave up, I can not explain this
>> better.
>
> You suggested that INT_MIN presents problems that make it possible
> for a conforming compiler not to handle it correctly.  I was replying
> (in part) to that point.
>
> As far as multicharacter constants are concerned, I disagree with Tim
> Rentsch's argument, though the standard is not entirely clear (perhaps
> because it's an edge case that the authors didn't carefully consider).
> In my opinion, since the standard says that the value of a
> multicharacter constant is of type int and is implementation-defined,
> it's reasonable to think that the intent is to require that the value
> must be representable as an int.  Otherwise it's not of type int, which
> violates the requirement.

I don't understand what the thinking is underlying this inference.
The constant expression -INT_MIN is of type int, yet may have a
value that is not representable as an int.  Similarly the constant
expression (int)1e15 has type int and yet may have a value that is
not representable as an int.  The constant expression 1e1000 is of
type double;  its value is necessarily representable as a double,
but that is because of an explicit statement restricting how the
value may be chosen.  Enumeration constants have type int, and we
know their values will necessarily be representable as an int, but
that is because of the constraint in 6.7.2.2 p2 forces the
defining expression to have a value representable as an int (or
give a constraint violation).  In these cases and also all the
other cases I can think of, knowing the type is never enough by
itself to know the value will be representable as that type:
either there is an explicit statement that forces the value to be
one that is representable, or the value may be one that is not
representable (as that type) and there is a constraint (or maybe
an explicit "shall" or similar) that determines how out-of-range
values are treated.  Why should the situation with character
constants be different?

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


Thread

Re: longer 'char literals' meaning in c antispam@math.uni.wroc.pl - 2020-05-05 00:47 +0000
  Re: longer 'char literals' meaning in c Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-04 20:08 -0700
  Re: longer 'char literals' meaning in c James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-05-04 23:52 -0400
    Re: longer 'char literals' meaning in c antispam@math.uni.wroc.pl - 2020-05-05 17:10 +0000
      Re: longer 'char literals' meaning in c Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-05 13:41 -0700
        Re: longer 'char literals' meaning in c antispam@math.uni.wroc.pl - 2020-05-05 22:29 +0000
          Re: longer 'char literals' meaning in c Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-05 16:18 -0700
            Re: longer 'char literals' meaning in c antispam@math.uni.wroc.pl - 2020-05-06 02:33 +0000
              Re: longer 'char literals' meaning in c Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-05 20:06 -0700
                Re: longer 'char literals' meaning in c antispam@math.uni.wroc.pl - 2020-05-06 18:57 +0000
                Re: longer 'char literals' meaning in c Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-06 13:37 -0700
                Re: longer 'char literals' meaning in c Spiros Bousbouras <spibou@gmail.com> - 2020-05-07 13:48 +0000
                Re: longer 'char literals' meaning in c Spiros Bousbouras <spibou@gmail.com> - 2020-05-07 13:58 +0000
                Re: longer 'char literals' meaning in c Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-05-24 17:36 -0700
                Re: longer 'char literals' meaning in c Spiros Bousbouras <spibou@gmail.com> - 2020-05-25 00:56 +0000
                Re: longer 'char literals' meaning in c Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-05-29 22:53 -0700
                Re: longer 'char literals' meaning in c Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-07 18:01 -0700
                Re: longer 'char literals' meaning in c Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-05-30 10:53 -0700
                Re: longer 'char literals' meaning in c Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-05-30 15:11 -0700
                Re: longer 'char literals' meaning in c Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-05-24 18:19 -0700
                Re: longer 'char literals' meaning in c James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-05-24 20:06 -0700
                Re: longer 'char literals' meaning in c Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-06-28 04:51 -0700
                Re: longer 'char literals' meaning in c James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-06-28 17:45 -0700
                Re: longer 'char literals' meaning in c Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-05-26 07:02 -0700
      Re: longer 'char literals' meaning in c James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-05-05 20:18 -0400
        Re: longer 'char literals' meaning in c antispam@math.uni.wroc.pl - 2020-05-06 20:01 +0000
          Re: longer 'char literals' meaning in c James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-05-06 18:20 -0400
            Re: longer 'char literals' meaning in c Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-06-28 04:42 -0700
              Re: longer 'char literals' meaning in c James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-06-28 17:13 -0700
    Re: longer 'char literals' meaning in c Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-06-03 09:08 -0700

csiph-web