Path: csiph.com!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: Command Languages Versus Programming Languages
Date: Tue, 26 Nov 2024 04:14:58 -0800
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <86plmiqji5.fsf@linuxsc.com>
References: <26a35ceb3dd8fe913f59c2ac8a2b01b99e462c2e@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 26 Nov 2024 13:15:08 +0100 (CET)
Injection-Info: dont-email.me; posting-host="1ebfc87b5a97bb6cfe9751ebbb383b2b"; logging-data="3626788"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qY9+7QAOgxVn+PGyvuw5fSz4tMS0TENE="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Rw05Nyx2YnaC0cnmG3PUGzycIoE= sha1:IFzUUiJIF1BDWMFz7KIfLvq3EoY=
Xref: csiph.com comp.lang.c++:121024
Richard Damon writes:
> On 11/23/24 9:43 AM, James Kuyper wrote:
>
>> On 11/23/24 09:05, Dan Cross wrote:
>>
>>> In article ,
>>> James Kuyper wrote:
>>
>> ...
>>
>>>> Your wording could easily give the false impression, to anyone
>>>> who didn't already know better, that promotion of unsigned char
>>>> to signed int is required by the standard, rather than it being
>>>> dependent upon whether UCHAR_MAX > INT_MAX.
>>>
>>> Actually I'm not sure that it did. Note the part that you quoted
>>> above that says, "the entire range values is expressible in a
>>> signed int." This implies UCHAR_MAX <= INT_MAX. (By "values" I
>>> meant, "values of that type", not specific values in any given
>>> program).
>>
>> You paired that assertion with "`unsigned char` has _rank_ lower
>> than _int_", which is a fact guaranteed by the standard, which
>> could easily give the impression that the comment about the range
>> of values was either explicitly stated in the standard, or
>> correctly inferrable from the statement about the ranks.
>
> I don't think unsigned char is guarateed by the standard to be
> less than that of int.
The integer conversion rank of unsigned char is guaranteed to be
less than the integer conversion rank of int (which incidentally is
the same as the integer conversion rank of unsigned int).
But the set of values of unsigned char is not guaranteed to be a
subset of the set of values of int.
> On a machine with wide bytes (like some DSP processors) sizeof int
> could be 1, which results is some unexpected results,
> like UCHAR_MAX > INT_MAX.
sizeof (int) == 1 is sufficient but not necessary.
As long as CHAR_BIT > 15, it is possible for UCHAR_MAX > INT_MAX
regardless of the value of sizeof (int).
It would be amusing to see an implementation where CHAR_BIT == 16,
and sizeof (int) == sizeof (long) == sizeof (long long) == 4, but
nevertheless UCHAR_MAX > INT_MAX.