Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

We want to create puppets that pull their own strings. -- Ann Marion


devel / comp.lang.c / Re: does a double cast to unsigned makes sense in any circumstance?

SubjectAuthor
* does a double cast to unsigned makes sense in any circumstance?Meredith Montgomery
+* Re: does a double cast to unsigned makes sense in any circumstance?Bart
|`- Re: does a double cast to unsigned makes sense in any circumstance?Meredith Montgomery
+* Re: does a double cast to unsigned makes sense in any circumstance?Andrey Tarasevich
|`* Re: does a double cast to unsigned makes sense in any circumstance?Meredith Montgomery
| `* Re: does a double cast to unsigned makes sense in any circumstance?James Kuyper
|  `* Re: does a double cast to unsigned makes sense in any circumstance?Tim Rentsch
|   `* Re: does a double cast to unsigned makes sense in any circumstance?james...@alumni.caltech.edu
|    `- Re: does a double cast to unsigned makes sense in any circumstance?Tim Rentsch
+* Re: does a double cast to unsigned makes sense in any circumstance?Bonita Montero
|`* Re: does a double cast to unsigned makes sense in any circumstance?Meredith Montgomery
| `* Re: does a double cast to unsigned makes sense in any circumstance?James Kuyper
|  +* Re: does a double cast to unsigned makes sense in any circumstance?Keith Thompson
|  |+- Re: does a double cast to unsigned makes sense in any circumstance?James Kuyper
|  |`* Re: does a double cast to unsigned makes sense in any circumstance?Meredith Montgomery
|  | `* Re: does a double cast to unsigned makes sense in any circumstance?Keith Thompson
|  |  `* Re: does a double cast to unsigned makes sense in any circumstance?Meredith Montgomery
|  |   +* Re: does a double cast to unsigned makes sense in any circumstance?James Kuyper
|  |   |`* Re: does a double cast to unsigned makes sense in any circumstance?Tim Rentsch
|  |   | `- Re: does a double cast to unsigned makes sense in any circumstance?james...@alumni.caltech.edu
|  |   `* Re: does a double cast to unsigned makes sense in any circumstance?Keith Thompson
|  |    `* Re: does a double cast to unsigned makes sense in any circumstance?Manfred
|  |     `* Re: does a double cast to unsigned makes sense in any circumstance?Keith Thompson
|  |      `- Re: does a double cast to unsigned makes sense in any circumstance?Richard Damon
|  `- Re: does a double cast to unsigned makes sense in any circumstance?Meredith Montgomery
+* Re: does a double cast to unsigned makes sense in any circumstance?Richard Damon
|+* Re: does a double cast to unsigned makes sense in any circumstance?Meredith Montgomery
||`* Re: does a double cast to unsigned makes sense in any circumstance?Richard Damon
|| `- Re: does a double cast to unsigned makes sense in any circumstance?Meredith Montgomery
|`- Re: does a double cast to unsigned makes sense in any circumstance?Bonita Montero
`* Re: does a double cast to unsigned makes sense in any circumstance?Tim Rentsch
 +- Re: does a double cast to unsigned makes sense in any circumstance?Meredith Montgomery
 `* Re: does a double cast to unsigned makes sense in any circumstance?Bonita Montero
  `* Re: does a double cast to unsigned makes sense in any circumstance?Öö Tiib
   `* Re: does a double cast to unsigned makes sense in any circumstance?Bonita Montero
    `- Re: does a double cast to unsigned makes sense in any circumstance?Öö Tiib

Pages:12
Re: does a double cast to unsigned makes sense in any circumstance?

<st28po$p1p$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20269&group=comp.lang.c#20269

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: does a double cast to unsigned makes sense in any circumstance?
Date: Fri, 28 Jan 2022 21:29:12 -0500
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <st28po$p1p$1@dont-email.me>
References: <86czl8kaew.fsf@levado.to> <sqvfed$rps$1@dont-email.me>
<8635lotrby.fsf@levado.to> <ss06le$h5n$1@dont-email.me>
<87y23fxt9p.fsf@nosuchdomain.example.com> <86a6fur0rh.fsf@levado.to>
<87tue2xbu5.fsf@nosuchdomain.example.com> <864k5n9wdw.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 Jan 2022 02:29:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ec161bfa19ec8c044acf5537a2d99725";
logging-data="25657"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18FeRjWnarvxSNSm5HMVkIFmG1fkDVJPHo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:v7NbMWkG8/9AoFh39Ln+xfO6sWo=
In-Reply-To: <864k5n9wdw.fsf@levado.to>
Content-Language: en-US
 by: James Kuyper - Sat, 29 Jan 2022 02:29 UTC

On 1/28/22 20:13, Meredith Montgomery wrote:
....
> What's a freestanding implementation?

"The two forms of conforming implementation are hosted and freestanding.
A conforming hosted implementation shall accept any strictly conforming
program. A conforming freestanding implementation shall accept any
strictly conforming program in which the use of the features specified
in the library clause (Clause 7) is confined to the contents of the
standard headers <float.h> , <iso646.h> , <limits.h> , <stdalign.h> ,
<stdarg.h> , <stdbool.h> , <stddef.h> , <stdint.h> , and <stdnoreturn.h>
.. Additionally, a conforming freestanding implementation shall accept
any strictly conforming program in which the use of the features
specified in the header <string.h> , except the following functions:
strdup , strndup , strcoll , strxfrm , strerror ." (4p6)

That last sentence is new in n2731.pdf, the latest draft of the CX 202X
that I have. It's not grammatically correct; I suspect that the word
"except" in the final sentence should have been "is confined to the use
of", paralleling the structure of the previous sentence.

Basically, freestanding implementations have no obligation to implement
most of the C standard library.

Re: does a double cast to unsigned makes sense in any circumstance?

<87fsp7ky9m.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20273&group=comp.lang.c#20273

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: does a double cast to unsigned makes sense in any circumstance?
Date: Fri, 28 Jan 2022 19:37:41 -0800
Organization: None to speak of
Lines: 55
Message-ID: <87fsp7ky9m.fsf@nosuchdomain.example.com>
References: <86czl8kaew.fsf@levado.to> <sqvfed$rps$1@dont-email.me>
<8635lotrby.fsf@levado.to> <ss06le$h5n$1@dont-email.me>
<87y23fxt9p.fsf@nosuchdomain.example.com> <86a6fur0rh.fsf@levado.to>
<87tue2xbu5.fsf@nosuchdomain.example.com> <864k5n9wdw.fsf@levado.to>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="7db0e57409d381c02446ec8e6e17a154";
logging-data="11515"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Jj4qEToNgv6sYvsj7X+18"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:vf17+2sEn/MU3rQs+zbScec6GA8=
sha1:ItvdXsrTPPJ40ZEZXRPe8ySRXMc=
 by: Keith Thompson - Sat, 29 Jan 2022 03:37 UTC

Meredith Montgomery <mmontgomery@levado.to> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Meredith Montgomery <mmontgomery@levado.to> writes:
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>> James Kuyper <jameskuyper@alumni.caltech.edu> writes:
>>>> [...]
>>>>> "... the value is converted by repeatedly adding ... one more than the
>>>>> maximum value that can be represented in the new type until the value is
>>>>> in the range of the new type." (6.3.1.3p2).
>>>>>
>>>>> It's the other direction that's dangerous: conversion of an integer
>>>>> value to a signed integer type that is not representable in that type
>>>>> has undefined behavior.
>>>>
>>>> No, converting an out-of-range integer value to a signed integer type
>>>> yields an implementation-defined result or raises an
>>>> implementation-defined signal. (C99 added the option of raising a
>>>> signal; in my opinion that was a bad idea.)
>>>
>>> Just curious --- why do you think a signal is a bad idea?
>>
>> A signal isn't inherently a bad idea, particularly if portable code can
>> handle it. But the fact that the signal is implementation-defined makes
>> that impossible. (And freestanding implementations needn't support
>> <signal.h>.)
>
> What's a freestanding implementation?

See section 4 of any edition of the C standard. I usually use
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf, a draft
that's close to C11.

The two forms of *conforming implementation* are hosted and
freestanding. A *conforming hosted implementation* shall accept any
strictly conforming program. A *conforming freestanding implementation*
shall accept any strictly conforming program in which the use of the
features specified in the library clause (clause 7) is confined to the
contents of the standard headers <float.h>, <iso646.h>, <limits.h>,
<stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and
<stdnoreturn.h>. A conforming implementation may have extensions
(including additional library functions), provided they do not alter
the behavior of any strictly conforming program.

Basically a hosted implementation is the kind that you're most likely to
encounter. It generates code that runs under an operating system, and
it supports the entire standard library. A freestanding implementation
targets an embedded system that might not have an operating system at
all. The only standard library headers that must be supported are the
ones that don't declare any functions. A freestanding implementation
might provide some library functions, but it isn't required to.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: does a double cast to unsigned makes sense in any circumstance?

<st3o51$jj1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20282&group=comp.lang.c#20282

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: does a double cast to unsigned makes sense in any circumstance?
Date: Sat, 29 Jan 2022 16:57:21 +0100
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <st3o51$jj1$1@dont-email.me>
References: <86czl8kaew.fsf@levado.to> <86y23gtmr0.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 Jan 2022 15:57:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cc7fbeb536b48379797b841bc0c934c6";
logging-data="20065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WZbIif9Z0gXPP1pTjhg0wEVZHuUHIphQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.1
Cancel-Lock: sha1:N4+BhXY7BOF9lyW3CSAxPHhdxcI=
In-Reply-To: <86y23gtmr0.fsf@linuxsc.com>
Content-Language: de-DE
 by: Bonita Montero - Sat, 29 Jan 2022 15:57 UTC

Am 16.01.2022 um 03:53 schrieb Tim Rentsch:
> Meredith Montgomery <mmontgomery@levado.to> writes:
>
>> I've seen this somewhere or I wrote this some time in the past for some
>> reason and I can't see how this make sense any longer. In a procedure
>> to read a numeric string and turn it into a number, we need to convert
>> each char-digit to some kind of integer:
>>
>> (uint64_t) (unsigned char) (s[pos] - '0');
>>
>> But the double cast here seems odd. I could have written this by
>> copying it from somewhere else. Today, what I would write is just
>>
>> (uint64_t) (s[pos] - '0');
>>
>> Am I making a mistake now? I can't anything wrong with this. Isn't a
>> char just an int? I'm turning an int into an unsigned integer (of a
>> larger size).
>
> The original context for the expression in question is this
> function:
>
>> [posted by Meredith Montgomery]
>>
>> #include <limits.h>
>> #include <inttypes.h>
>>
>> int scan_ulong(register char *s, register unsigned long *u)
>> {
>> register unsigned int pos;
>> register unsigned long r;
>> register unsigned long c;
>>
>> pos = 0; r = 0;
>>
>> for ( ;; ) {
>> c = (unsigned long) (unsigned char) (s[pos] - '0');
>> if (c < 10) {
>> if( ((ULONG_MAX - c) / 10) >= r)
>> r = r * 10 + c;
>> else return -1; /* lack of space */
>> ++pos; continue;
>> }
>> break;
>> }
>>
>> *u = r;
>> return pos;
>> }
>
> In this context, the casts are superfluous. Just write
>
> c = s[pos] - '0';

This makes different results if "s[pos] - '0'" is negative.

>
> and the right thing will happen, because the assignment to 'c'
> converts the value on the right hand side to 'unsigned long',
> and so takes care of any negative values.

Re: does a double cast to unsigned makes sense in any circumstance?

<09fcd422-c929-4c5b-a15a-099bbe4a8e81n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20284&group=comp.lang.c#20284

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:1418:: with SMTP id d24mr8723085qkj.513.1643478892215;
Sat, 29 Jan 2022 09:54:52 -0800 (PST)
X-Received: by 2002:a05:6214:226c:: with SMTP id gs12mr11723595qvb.4.1643478892071;
Sat, 29 Jan 2022 09:54:52 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 29 Jan 2022 09:54:51 -0800 (PST)
In-Reply-To: <st3o51$jj1$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=94.246.251.164; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 94.246.251.164
References: <86czl8kaew.fsf@levado.to> <86y23gtmr0.fsf@linuxsc.com> <st3o51$jj1$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <09fcd422-c929-4c5b-a15a-099bbe4a8e81n@googlegroups.com>
Subject: Re: does a double cast to unsigned makes sense in any circumstance?
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Sat, 29 Jan 2022 17:54:52 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 65
 by: Öö Tiib - Sat, 29 Jan 2022 17:54 UTC

On Saturday, 29 January 2022 at 17:57:34 UTC+2, Bonita Montero wrote:
> Am 16.01.2022 um 03:53 schrieb Tim Rentsch:
> > Meredith Montgomery <mmont...@levado.to> writes:
> >
> >> I've seen this somewhere or I wrote this some time in the past for some
> >> reason and I can't see how this make sense any longer. In a procedure
> >> to read a numeric string and turn it into a number, we need to convert
> >> each char-digit to some kind of integer:
> >>
> >> (uint64_t) (unsigned char) (s[pos] - '0');
> >>
> >> But the double cast here seems odd. I could have written this by
> >> copying it from somewhere else. Today, what I would write is just
> >>
> >> (uint64_t) (s[pos] - '0');
> >>
> >> Am I making a mistake now? I can't anything wrong with this. Isn't a
> >> char just an int? I'm turning an int into an unsigned integer (of a
> >> larger size).
> >
> > The original context for the expression in question is this
> > function:
> >
> >> [posted by Meredith Montgomery]
> >>
> >> #include <limits.h>
> >> #include <inttypes.h>
> >>
> >> int scan_ulong(register char *s, register unsigned long *u)
> >> {
> >> register unsigned int pos;
> >> register unsigned long r;
> >> register unsigned long c;
> >>
> >> pos = 0; r = 0;
> >>
> >> for ( ;; ) {
> >> c = (unsigned long) (unsigned char) (s[pos] - '0');
> >> if (c < 10) {
> >> if( ((ULONG_MAX - c) / 10) >= r)
> >> r = r * 10 + c;
> >> else return -1; /* lack of space */
> >> ++pos; continue;
> >> }
> >> break;
> >> }
> >>
> >> *u = r;
> >> return pos;
> >> }
> >
> > In this context, the casts are superfluous. Just write
> >
> > c = s[pos] - '0';
> This makes different results if "s[pos] - '0'" is negative.

Your usual incapability to read next sentence below that addresses it
specifically noted.

> >
> > and the right thing will happen, because the assignment to 'c'
> > converts the value on the right hand side to 'unsigned long',
> > and so takes care of any negative values.

Works, unlike your pathetically borken functions in another thread:
https://groups.google.com/g/comp.lang.c/c/pfgpeqAm0h8/m/y9MHNBwuAQAJ

Re: does a double cast to unsigned makes sense in any circumstance?

<st4u3j$st8$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20291&group=comp.lang.c#20291

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!t+tkPsKqhWrsx9rWnrAETg.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c
Subject: Re: does a double cast to unsigned makes sense in any circumstance?
Date: Sun, 30 Jan 2022 03:45:06 +0100
Organization: Aioe.org NNTP Server
Message-ID: <st4u3j$st8$1@gioia.aioe.org>
References: <86czl8kaew.fsf@levado.to> <sqvfed$rps$1@dont-email.me>
<8635lotrby.fsf@levado.to> <ss06le$h5n$1@dont-email.me>
<87y23fxt9p.fsf@nosuchdomain.example.com> <86a6fur0rh.fsf@levado.to>
<87tue2xbu5.fsf@nosuchdomain.example.com> <864k5n9wdw.fsf@levado.to>
<87fsp7ky9m.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="29608"; posting-host="t+tkPsKqhWrsx9rWnrAETg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Manfred - Sun, 30 Jan 2022 02:45 UTC

On 1/29/2022 4:37 AM, Keith Thompson wrote:
> Meredith Montgomery <mmontgomery@levado.to> writes:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>> Meredith Montgomery <mmontgomery@levado.to> writes:
>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>>> James Kuyper <jameskuyper@alumni.caltech.edu> writes:
>>>>> [...]
>>>>>> "... the value is converted by repeatedly adding ... one more than the
>>>>>> maximum value that can be represented in the new type until the value is
>>>>>> in the range of the new type." (6.3.1.3p2).
>>>>>>
>>>>>> It's the other direction that's dangerous: conversion of an integer
>>>>>> value to a signed integer type that is not representable in that type
>>>>>> has undefined behavior.
>>>>>
>>>>> No, converting an out-of-range integer value to a signed integer type
>>>>> yields an implementation-defined result or raises an
>>>>> implementation-defined signal. (C99 added the option of raising a
>>>>> signal; in my opinion that was a bad idea.)
>>>>
>>>> Just curious --- why do you think a signal is a bad idea?
>>>
>>> A signal isn't inherently a bad idea, particularly if portable code can
>>> handle it. But the fact that the signal is implementation-defined makes
>>> that impossible. (And freestanding implementations needn't support
>>> <signal.h>.)
>>
>> What's a freestanding implementation?
>
> See section 4 of any edition of the C standard. I usually use
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf, a draft
> that's close to C11.
>
> The two forms of *conforming implementation* are hosted and
> freestanding. A *conforming hosted implementation* shall accept any
> strictly conforming program. A *conforming freestanding implementation*
> shall accept any strictly conforming program in which the use of the
> features specified in the library clause (clause 7) is confined to the
> contents of the standard headers <float.h>, <iso646.h>, <limits.h>,
> <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and
> <stdnoreturn.h>. A conforming implementation may have extensions
> (including additional library functions), provided they do not alter
> the behavior of any strictly conforming program.
>
> Basically a hosted implementation is the kind that you're most likely to
> encounter. It generates code that runs under an operating system, and
> it supports the entire standard library. A freestanding implementation
> targets an embedded system that might not have an operating system at
> all. The only standard library headers that must be supported are the
> ones that don't declare any functions. A freestanding implementation
> might provide some library functions, but it isn't required to.
>

A freestanding implementation might also target the OS itself of a
common system (not necessarily embedded), right?

Re: does a double cast to unsigned makes sense in any circumstance?

<87bkztlki5.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20293&group=comp.lang.c#20293

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: does a double cast to unsigned makes sense in any circumstance?
Date: Sun, 30 Jan 2022 00:01:54 -0800
Organization: None to speak of
Lines: 93
Message-ID: <87bkztlki5.fsf@nosuchdomain.example.com>
References: <86czl8kaew.fsf@levado.to> <sqvfed$rps$1@dont-email.me>
<8635lotrby.fsf@levado.to> <ss06le$h5n$1@dont-email.me>
<87y23fxt9p.fsf@nosuchdomain.example.com> <86a6fur0rh.fsf@levado.to>
<87tue2xbu5.fsf@nosuchdomain.example.com> <864k5n9wdw.fsf@levado.to>
<87fsp7ky9m.fsf@nosuchdomain.example.com>
<st4u3j$st8$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="a6fb2640787a694e66b51accde4bf12d";
logging-data="20730"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18p/6c7xe7aYj7CubQK9DAa"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:MN8DxCAc345t5h1xv24ZWQzwKSY=
sha1:LnMUzFmRaiM58A8LNwBn6rFjpL4=
 by: Keith Thompson - Sun, 30 Jan 2022 08:01 UTC

Manfred <noname@add.invalid> writes:
> On 1/29/2022 4:37 AM, Keith Thompson wrote:
>> Meredith Montgomery <mmontgomery@levado.to> writes:
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>> Meredith Montgomery <mmontgomery@levado.to> writes:
>>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>>>> James Kuyper <jameskuyper@alumni.caltech.edu> writes:
>>>>>> [...]
>>>>>>> "... the value is converted by repeatedly adding ... one more than the
>>>>>>> maximum value that can be represented in the new type until the value is
>>>>>>> in the range of the new type." (6.3.1.3p2).
>>>>>>>
>>>>>>> It's the other direction that's dangerous: conversion of an integer
>>>>>>> value to a signed integer type that is not representable in that type
>>>>>>> has undefined behavior.
>>>>>>
>>>>>> No, converting an out-of-range integer value to a signed integer type
>>>>>> yields an implementation-defined result or raises an
>>>>>> implementation-defined signal. (C99 added the option of raising a
>>>>>> signal; in my opinion that was a bad idea.)
>>>>>
>>>>> Just curious --- why do you think a signal is a bad idea?
>>>>
>>>> A signal isn't inherently a bad idea, particularly if portable code can
>>>> handle it. But the fact that the signal is implementation-defined makes
>>>> that impossible. (And freestanding implementations needn't support
>>>> <signal.h>.)
>>>
>>> What's a freestanding implementation?
>> See section 4 of any edition of the C standard. I usually use
>> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf, a draft
>> that's close to C11.
>> The two forms of *conforming implementation* are hosted and
>> freestanding. A *conforming hosted implementation* shall accept any
>> strictly conforming program. A *conforming freestanding implementation*
>> shall accept any strictly conforming program in which the use of the
>> features specified in the library clause (clause 7) is confined to the
>> contents of the standard headers <float.h>, <iso646.h>, <limits.h>,
>> <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and
>> <stdnoreturn.h>. A conforming implementation may have extensions
>> (including additional library functions), provided they do not alter
>> the behavior of any strictly conforming program.
>> Basically a hosted implementation is the kind that you're most
>> likely to
>> encounter. It generates code that runs under an operating system, and
>> it supports the entire standard library. A freestanding implementation
>> targets an embedded system that might not have an operating system at
>> all. The only standard library headers that must be supported are the
>> ones that don't declare any functions. A freestanding implementation
>> might provide some library functions, but it isn't required to.
>
> A freestanding implementation might also target the OS itself of a
> common system (not necessarily embedded), right?

Sure. Any implementation that meet's the standard's requirements can be
a conforming freestanding implementation -- even one that targets an OS.
You could call an implementation "freestanding" even if it's just
because you haven't implemented all the required parts of the standard
library.

The standard does have more to say about freestanding implementations
(N1570 5.1.2.1):

In a freestanding environment (in which C program execution
may take place without any benefit of an operating system),
the name and type of the function called at program startup are
implementation-defined. Any library facilities available to a
freestanding program, other than the minimal set required by
clause 4, are implementation-defined.

The effect of program termination in a freestanding environment
is implementation-defined.

And the ANSI C Rationale:

By defining conforming implementations in terms of the programs they
accept, the Standard leaves open the door for a broad class of
extensions as part of a conforming implementation. By defining both
conforming hosted and conforming freestanding implementations, the
Standard recognizes the use of C to write such programs as operating
systems and ROM-based applications, as well as more conventional
hosted applications. Beyond this two-level scheme, no additional
subsetting is defined for C, since the Committee felt strongly that
too many levels dilutes the effectiveness of a standard.

I think the intent is that freestanding implementations are for embedded
systems, likely with no OS, or you're using the implementation to build
the OS, but it's not a strict requirement.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: does a double cast to unsigned makes sense in any circumstance?

<st5vkl$o02$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20295&group=comp.lang.c#20295

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: does a double cast to unsigned makes sense in any circumstance?
Date: Sun, 30 Jan 2022 13:17:24 +0100
Organization: A noiseless patient Spider
Lines: 78
Message-ID: <st5vkl$o02$1@dont-email.me>
References: <86czl8kaew.fsf@levado.to> <86y23gtmr0.fsf@linuxsc.com>
<st3o51$jj1$1@dont-email.me>
<09fcd422-c929-4c5b-a15a-099bbe4a8e81n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 30 Jan 2022 12:17:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="709f4beeffc1b050bd593177706dc592";
logging-data="24578"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19N+Fh0J6kgOOwPBZURx7NvMfQU9RCRMhI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.1
Cancel-Lock: sha1:n/EfVS7jDJYW1at1+WUMVc57k5I=
In-Reply-To: <09fcd422-c929-4c5b-a15a-099bbe4a8e81n@googlegroups.com>
Content-Language: de-DE
 by: Bonita Montero - Sun, 30 Jan 2022 12:17 UTC

Am 29.01.2022 um 18:54 schrieb Öö Tiib:
> On Saturday, 29 January 2022 at 17:57:34 UTC+2, Bonita Montero wrote:
>> Am 16.01.2022 um 03:53 schrieb Tim Rentsch:
>>> Meredith Montgomery <mmont...@levado.to> writes:
>>>
>>>> I've seen this somewhere or I wrote this some time in the past for some
>>>> reason and I can't see how this make sense any longer. In a procedure
>>>> to read a numeric string and turn it into a number, we need to convert
>>>> each char-digit to some kind of integer:
>>>>
>>>> (uint64_t) (unsigned char) (s[pos] - '0');
>>>>
>>>> But the double cast here seems odd. I could have written this by
>>>> copying it from somewhere else. Today, what I would write is just
>>>>
>>>> (uint64_t) (s[pos] - '0');
>>>>
>>>> Am I making a mistake now? I can't anything wrong with this. Isn't a
>>>> char just an int? I'm turning an int into an unsigned integer (of a
>>>> larger size).
>>>
>>> The original context for the expression in question is this
>>> function:
>>>
>>>> [posted by Meredith Montgomery]
>>>>
>>>> #include <limits.h>
>>>> #include <inttypes.h>
>>>>
>>>> int scan_ulong(register char *s, register unsigned long *u)
>>>> {
>>>> register unsigned int pos;
>>>> register unsigned long r;
>>>> register unsigned long c;
>>>>
>>>> pos = 0; r = 0;
>>>>
>>>> for ( ;; ) {
>>>> c = (unsigned long) (unsigned char) (s[pos] - '0');
>>>> if (c < 10) {
>>>> if( ((ULONG_MAX - c) / 10) >= r)
>>>> r = r * 10 + c;
>>>> else return -1; /* lack of space */
>>>> ++pos; continue;
>>>> }
>>>> break;
>>>> }
>>>>
>>>> *u = r;
>>>> return pos;
>>>> }
>>>
>>> In this context, the casts are superfluous. Just write
>>>
>>> c = s[pos] - '0';
>> This makes different results if "s[pos] - '0'" is negative.
>
> Your usual incapability to read next sentence below that addresses it
> specifically noted.
>
>>>
>>> and the right thing will happen, because the assignment to 'c'
>>> converts the value on the right hand side to 'unsigned long',
>>> and so takes care of any negative values.

That's not true. The compiler may give a negative value
converted to an unsigned value:

__declspec(noinline)
unsigned long f( char c )
{ return c - '0';
}

movsx eax, cl
sub eax, 48
ret 0

Re: does a double cast to unsigned makes sense in any circumstance?

<RlAJJ.23508$1_.9793@fx37.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20304&group=comp.lang.c#20304

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx37.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.5.1
Subject: Re: does a double cast to unsigned makes sense in any circumstance?
Content-Language: en-US
Newsgroups: comp.lang.c
References: <86czl8kaew.fsf@levado.to> <sqvfed$rps$1@dont-email.me>
<8635lotrby.fsf@levado.to> <ss06le$h5n$1@dont-email.me>
<87y23fxt9p.fsf@nosuchdomain.example.com> <86a6fur0rh.fsf@levado.to>
<87tue2xbu5.fsf@nosuchdomain.example.com> <864k5n9wdw.fsf@levado.to>
<87fsp7ky9m.fsf@nosuchdomain.example.com> <st4u3j$st8$1@gioia.aioe.org>
<87bkztlki5.fsf@nosuchdomain.example.com>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <87bkztlki5.fsf@nosuchdomain.example.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 95
Message-ID: <RlAJJ.23508$1_.9793@fx37.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 30 Jan 2022 12:59:15 -0500
X-Received-Bytes: 6424
 by: Richard Damon - Sun, 30 Jan 2022 17:59 UTC

On 1/30/22 3:01 AM, Keith Thompson wrote:
> Manfred <noname@add.invalid> writes:
>> On 1/29/2022 4:37 AM, Keith Thompson wrote:
>>> Meredith Montgomery <mmontgomery@levado.to> writes:
>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>>> Meredith Montgomery <mmontgomery@levado.to> writes:
>>>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>>>>> James Kuyper <jameskuyper@alumni.caltech.edu> writes:
>>>>>>> [...]
>>>>>>>> "... the value is converted by repeatedly adding ... one more than the
>>>>>>>> maximum value that can be represented in the new type until the value is
>>>>>>>> in the range of the new type." (6.3.1.3p2).
>>>>>>>>
>>>>>>>> It's the other direction that's dangerous: conversion of an integer
>>>>>>>> value to a signed integer type that is not representable in that type
>>>>>>>> has undefined behavior.
>>>>>>>
>>>>>>> No, converting an out-of-range integer value to a signed integer type
>>>>>>> yields an implementation-defined result or raises an
>>>>>>> implementation-defined signal. (C99 added the option of raising a
>>>>>>> signal; in my opinion that was a bad idea.)
>>>>>>
>>>>>> Just curious --- why do you think a signal is a bad idea?
>>>>>
>>>>> A signal isn't inherently a bad idea, particularly if portable code can
>>>>> handle it. But the fact that the signal is implementation-defined makes
>>>>> that impossible. (And freestanding implementations needn't support
>>>>> <signal.h>.)
>>>>
>>>> What's a freestanding implementation?
>>> See section 4 of any edition of the C standard. I usually use
>>> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf, a draft
>>> that's close to C11.
>>> The two forms of *conforming implementation* are hosted and
>>> freestanding. A *conforming hosted implementation* shall accept any
>>> strictly conforming program. A *conforming freestanding implementation*
>>> shall accept any strictly conforming program in which the use of the
>>> features specified in the library clause (clause 7) is confined to the
>>> contents of the standard headers <float.h>, <iso646.h>, <limits.h>,
>>> <stdalign.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, <stdint.h>, and
>>> <stdnoreturn.h>. A conforming implementation may have extensions
>>> (including additional library functions), provided they do not alter
>>> the behavior of any strictly conforming program.
>>> Basically a hosted implementation is the kind that you're most
>>> likely to
>>> encounter. It generates code that runs under an operating system, and
>>> it supports the entire standard library. A freestanding implementation
>>> targets an embedded system that might not have an operating system at
>>> all. The only standard library headers that must be supported are the
>>> ones that don't declare any functions. A freestanding implementation
>>> might provide some library functions, but it isn't required to.
>>
>> A freestanding implementation might also target the OS itself of a
>> common system (not necessarily embedded), right?
>
> Sure. Any implementation that meet's the standard's requirements can be
> a conforming freestanding implementation -- even one that targets an OS.
> You could call an implementation "freestanding" even if it's just
> because you haven't implemented all the required parts of the standard
> library.
>
> The standard does have more to say about freestanding implementations
> (N1570 5.1.2.1):
>
> In a freestanding environment (in which C program execution
> may take place without any benefit of an operating system),
> the name and type of the function called at program startup are
> implementation-defined. Any library facilities available to a
> freestanding program, other than the minimal set required by
> clause 4, are implementation-defined.
>
> The effect of program termination in a freestanding environment
> is implementation-defined.
>
> And the ANSI C Rationale:
>
> By defining conforming implementations in terms of the programs they
> accept, the Standard leaves open the door for a broad class of
> extensions as part of a conforming implementation. By defining both
> conforming hosted and conforming freestanding implementations, the
> Standard recognizes the use of C to write such programs as operating
> systems and ROM-based applications, as well as more conventional
> hosted applications. Beyond this two-level scheme, no additional
> subsetting is defined for C, since the Committee felt strongly that
> too many levels dilutes the effectiveness of a standard.
>
> I think the intent is that freestanding implementations are for embedded
> systems, likely with no OS, or you're using the implementation to build
> the OS, but it's not a strict requirement.
>

I suppose that means that most 'Windows' implementations are technically
'freestanding' since the program starts at winmain not main (or just not
conforming, which also sounds sort of right).

Re: does a double cast to unsigned makes sense in any circumstance?

<1e8187ef-8fa7-4439-aae7-8ad8d1e1a9f6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20313&group=comp.lang.c#20313

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:1418:: with SMTP id d24mr12094438qkj.513.1643615613338;
Sun, 30 Jan 2022 23:53:33 -0800 (PST)
X-Received: by 2002:a05:620a:2702:: with SMTP id b2mr12317508qkp.52.1643615613163;
Sun, 30 Jan 2022 23:53:33 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 30 Jan 2022 23:53:33 -0800 (PST)
In-Reply-To: <st5vkl$o02$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=84.50.190.130; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 84.50.190.130
References: <86czl8kaew.fsf@levado.to> <86y23gtmr0.fsf@linuxsc.com>
<st3o51$jj1$1@dont-email.me> <09fcd422-c929-4c5b-a15a-099bbe4a8e81n@googlegroups.com>
<st5vkl$o02$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1e8187ef-8fa7-4439-aae7-8ad8d1e1a9f6n@googlegroups.com>
Subject: Re: does a double cast to unsigned makes sense in any circumstance?
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Mon, 31 Jan 2022 07:53:33 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 89
 by: Öö Tiib - Mon, 31 Jan 2022 07:53 UTC

On Sunday, 30 January 2022 at 14:17:37 UTC+2, Bonita Montero wrote:
> Am 29.01.2022 um 18:54 schrieb Öö Tiib:
> > On Saturday, 29 January 2022 at 17:57:34 UTC+2, Bonita Montero wrote:
> >> Am 16.01.2022 um 03:53 schrieb Tim Rentsch:
> >>> Meredith Montgomery <mmont...@levado.to> writes:
> >>>
> >>>> I've seen this somewhere or I wrote this some time in the past for some
> >>>> reason and I can't see how this make sense any longer. In a procedure
> >>>> to read a numeric string and turn it into a number, we need to convert
> >>>> each char-digit to some kind of integer:
> >>>>
> >>>> (uint64_t) (unsigned char) (s[pos] - '0');
> >>>>
> >>>> But the double cast here seems odd. I could have written this by
> >>>> copying it from somewhere else. Today, what I would write is just
> >>>>
> >>>> (uint64_t) (s[pos] - '0');
> >>>>
> >>>> Am I making a mistake now? I can't anything wrong with this. Isn't a
> >>>> char just an int? I'm turning an int into an unsigned integer (of a
> >>>> larger size).
> >>>
> >>> The original context for the expression in question is this
> >>> function:
> >>>
> >>>> [posted by Meredith Montgomery]
> >>>>
> >>>> #include <limits.h>
> >>>> #include <inttypes.h>
> >>>>
> >>>> int scan_ulong(register char *s, register unsigned long *u)
> >>>> {
> >>>> register unsigned int pos;
> >>>> register unsigned long r;
> >>>> register unsigned long c;
> >>>>
> >>>> pos = 0; r = 0;
> >>>>
> >>>> for ( ;; ) {
> >>>> c = (unsigned long) (unsigned char) (s[pos] - '0');
> >>>> if (c < 10) {
> >>>> if( ((ULONG_MAX - c) / 10) >= r)
> >>>> r = r * 10 + c;
> >>>> else return -1; /* lack of space */
> >>>> ++pos; continue;
> >>>> }
> >>>> break;
> >>>> }
> >>>>
> >>>> *u = r;
> >>>> return pos;
> >>>> }
> >>>
> >>> In this context, the casts are superfluous. Just write
> >>>
> >>> c = s[pos] - '0';
> >> This makes different results if "s[pos] - '0'" is negative.
> >
> > Your usual incapability to read next sentence below that addresses it
> > specifically noted.
> >
> >>>
> >>> and the right thing will happen, because the assignment to 'c'
> >>> converts the value on the right hand side to 'unsigned long',
> >>> and so takes care of any negative values.
>
> That's not true. The compiler may give a negative value
> converted to an unsigned value:
>
> __declspec(noinline)
> unsigned long f( char c )
> {
> return c - '0';
> }
>
> movsx eax, cl
> sub eax, 48
> ret 0

And little negative value converted to unsigned value does not
satisfy < 10. Works, unlike your pathetically borken functions
in another thread:
https://groups.google.com/g/comp.lang.c/c/pfgpeqAm0h8/m/y9MHNBwuAQAJ

Re: does a double cast to unsigned makes sense in any circumstance?

<86k0ebkuvy.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20333&group=comp.lang.c#20333

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: does a double cast to unsigned makes sense in any circumstance?
Date: Thu, 03 Feb 2022 22:28:49 -0800
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <86k0ebkuvy.fsf@linuxsc.com>
References: <86czl8kaew.fsf@levado.to> <sqvfed$rps$1@dont-email.me> <8635lotrby.fsf@levado.to> <ss06le$h5n$1@dont-email.me> <87y23fxt9p.fsf@nosuchdomain.example.com> <86a6fur0rh.fsf@levado.to> <87tue2xbu5.fsf@nosuchdomain.example.com> <864k5n9wdw.fsf@levado.to> <st28po$p1p$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="e5e1159670f97e706efea2e630831efe";
logging-data="12448"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zpwm4j4fpaxlkYW95+nZXMqyF14XPK8c="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:OQP+6B6iEiAxDIu5J73QhP1naFE=
sha1:q853ahsq6rgRR8S+yiDHuE0zJb8=
 by: Tim Rentsch - Fri, 4 Feb 2022 06:28 UTC

James Kuyper <jameskuyper@alumni.caltech.edu> writes:

> On 1/28/22 20:13, Meredith Montgomery wrote:
> ...
>
>> What's a freestanding implementation?
>
> "The two forms of conforming implementation are hosted and freestanding.
> A conforming hosted implementation shall accept any strictly conforming
> program. A conforming freestanding implementation shall accept any
> strictly conforming program in which the use of the features specified
> in the library clause (Clause 7) is confined to the contents of the
> standard headers <float.h> , <iso646.h> , <limits.h> , <stdalign.h> ,
> <stdarg.h> , <stdbool.h> , <stddef.h> , <stdint.h> , and <stdnoreturn.h>
> . Additionally, a conforming freestanding implementation shall accept
> any strictly conforming program in which the use of the features
> specified in the header <string.h> , except the following functions:
> strdup , strndup , strcoll , strxfrm , strerror ." (4p6)
>
> That last sentence is new in n2731.pdf, the latest draft of the CX 202X
> that I have. It's not grammatically correct; I suspect that the word
> "except" in the final sentence should have been "is confined to the use
> of", paralleling the structure of the previous sentence.

Surely what is intended is just the opposite: interfaces in <string.h>
may be used, except that strdup, strndup, strcoll, strxfrm, strerror
may not be used.

Re: does a double cast to unsigned makes sense in any circumstance?

<3ed21f89-22c2-43b8-9f6f-5084278b0ac8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20347&group=comp.lang.c#20347

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:192:: with SMTP id s18mr284983qtw.268.1644000231913;
Fri, 04 Feb 2022 10:43:51 -0800 (PST)
X-Received: by 2002:ae9:ef41:: with SMTP id d62mr290755qkg.282.1644000231711;
Fri, 04 Feb 2022 10:43:51 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 4 Feb 2022 10:43:51 -0800 (PST)
In-Reply-To: <86k0ebkuvy.fsf@linuxsc.com>
Injection-Info: google-groups.googlegroups.com; posting-host=108.48.119.9; posting-account=Ix1u_AoAAAAILVQeRkP2ENwli-Uv6vO8
NNTP-Posting-Host: 108.48.119.9
References: <86czl8kaew.fsf@levado.to> <sqvfed$rps$1@dont-email.me>
<8635lotrby.fsf@levado.to> <ss06le$h5n$1@dont-email.me> <87y23fxt9p.fsf@nosuchdomain.example.com>
<86a6fur0rh.fsf@levado.to> <87tue2xbu5.fsf@nosuchdomain.example.com>
<864k5n9wdw.fsf@levado.to> <st28po$p1p$1@dont-email.me> <86k0ebkuvy.fsf@linuxsc.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3ed21f89-22c2-43b8-9f6f-5084278b0ac8n@googlegroups.com>
Subject: Re: does a double cast to unsigned makes sense in any circumstance?
From: jameskuy...@alumni.caltech.edu (james...@alumni.caltech.edu)
Injection-Date: Fri, 04 Feb 2022 18:43:51 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 18
 by: james...@alumni.calt - Fri, 4 Feb 2022 18:43 UTC

On Friday, February 4, 2022 at 1:29:20 AM UTC-5, Tim Rentsch wrote:
> James Kuyper <james...@alumni.caltech.edu> writes:
....
> > . Additionally, a conforming freestanding implementation shall accept
> > any strictly conforming program in which the use of the features
> > specified in the header <string.h> , except the following functions:
> > strdup , strndup , strcoll , strxfrm , strerror ." (4p6)
> >
> > That last sentence is new in n2731.pdf, the latest draft of the CX 202X
> > that I have. It's not grammatically correct; I suspect that the word
> > "except" in the final sentence should have been "is confined to the use
> > of", paralleling the structure of the previous sentence.
> Surely what is intended is just the opposite: interfaces in <string.h>
> may be used, except that strdup, strndup, strcoll, strxfrm, strerror
> may not be used.

You might be right about that; it does make sense. However, regardless of what
they actually meant, the actual wording was messed up. It doesn't clearly
express either of our guesses as to the intended meaning.

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor