Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Most legends have their basis in facts. -- Kirk, "And The Children Shall Lead", stardate 5029.5


devel / comp.lang.c / Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

SubjectAuthor
* "Catch-23: The New C Standard,Sets the World on Fire" by TerenceLynn McGuire
+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJim Kelly
|`- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceLynn McGuire
+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Rene Kita
|`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Kenny McCormack
| +- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Scott Lurndal
| `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Rene Kita
|  `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Kenny McCormack
|   +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Dan Cross
|   |+* (realloc) Angels and pins (Was: "Catch-23: The New C Standard,Sets the World on Kenny McCormack
|   ||`- Re: (realloc) Angels and pins (Was: "Catch-23: The New C Standard,Sets the WorldDan Cross
|   |`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Ben Bacarisse
|   | +- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Dan Cross
|   | `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|   `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDavid Brown
+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceLynn McGuire
| `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Ben Bacarisse
|  +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Dan Cross
|  |+- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceOpus
|  |+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Ben Bacarisse
|  ||+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Dan Cross
|  |||+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDavid Brown
|  ||||+- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Scott Lurndal
|  ||||+- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|  |||||`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDavid Brown
|  ||||| +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||| |`- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  ||||| `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|  ||||`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with John Forkosh
|  |||| +- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDavid Brown
|  |||| `* Re: "Catch-23: The New C Standard,Sets the World on Fire" byKaz Kylheku
|  ||||  `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  ||||   +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   |+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|  ||||   ||+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   |||`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|  ||||   ||| +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   ||| |+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   ||| ||`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   ||| || +- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   ||| || `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceMalcolm McLean
|  ||||   ||| ||  `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||   ||| |`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||   ||| | `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceBart
|  ||||   ||| |  +- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||   ||| |  `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Ben Bacarisse
|  ||||   ||| |   `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceBart
|  ||||   ||| +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   ||| |+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|  ||||   ||| ||`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   ||| || `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|  ||||   ||| ||  +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   ||| ||  |`- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|  ||||   ||| ||  `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  ||||   ||| |`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Spiros Bousbouras
|  ||||   ||| | `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   ||| |  `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|  ||||   ||| `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  ||||   ||`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   || `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|  ||||   ||  `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   ||   `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|  ||||   ||    `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   ||     `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDan Cross
|  ||||   ||      `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   ||       `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Kalevi Kolttonen
|  ||||   ||        `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceBart
|  ||||   ||         `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Kalevi Kolttonen
|  ||||   |+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||   ||`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   || +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   || |+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   || ||+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   || |||+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   || ||||`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   || |||| +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   || |||| |`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   || |||| | +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceÖö Tiib
|  ||||   || |||| | |`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   || |||| | | +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||   || |||| | | |`* Re: "Catch-23: The New C Standard,Sets the World on Fire" byIke Naar
|  ||||   || |||| | | | +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Ben Bacarisse
|  ||||   || |||| | | | |`- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceÖö Tiib
|  ||||   || |||| | | | `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   || |||| | | `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceÖö Tiib
|  ||||   || |||| | |  `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   || |||| | |   `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   || |||| | |    +- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   || |||| | |    `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  ||||   || |||| | |     `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejames...@alumni.caltech.edu
|  ||||   || |||| | |      +- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDavid Brown
|  ||||   || |||| | |      `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  ||||   || |||| | |       `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejames...@alumni.caltech.edu
|  ||||   || |||| | |        `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  ||||   || |||| | +- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   || |||| | +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   || |||| | |+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Scott Lurndal
|  ||||   || |||| | ||+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   || |||| | |||`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terencejak
|  ||||   || |||| | ||+- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||   || |||| | ||`- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   || |||| | |`- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   || |||| | +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||   || |||| | `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceDavid Brown
|  ||||   || |||| `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||   || |||`- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||   || ||`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceJames Kuyper
|  ||||   || |`- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  ||||   || `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Keith Thompson
|  ||||   |`- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  ||||   `* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Ben Bacarisse
|  |||`- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Ben Bacarisse
|  ||`- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  |+* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  |`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Phil Carmody
|  +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Lowell Gilbert
|  +* Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
|  `- Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Tim Rentsch
+- Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceBonita Montero
`* Re: "Catch-23: The New C Standard,Sets the World on Fire" by TerenceMichael S

Pages:12345678
Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<86r0st3zj0.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan
Date: Sun, 09 Apr 2023 07:23:31 -0700
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <86r0st3zj0.fsf@linuxsc.com>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk> <u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk> <u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me> <u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="2b6f87d227a563a0c00d2eacd0f30cf4";
logging-data="1851201"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qc55yRnqZ6EzHQR6LVxjURkGXCI1dYKE="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:KaPdrqSpZbVvPU6Jb8laq3FLN+Q=
sha1:wGrWVB4YXzxOn0Z27VTWbLUTmkQ=
 by: Tim Rentsch - Sun, 9 Apr 2023 14:23 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:

[miscellaneous suggestions taken out]

> On 2023-04-06, John Forkosh <forkosh@panix.com> wrote:
>
>> void *realloc0 ( void *ptr, size_t size ) {
>> void *reptr = NULL;
>> if ( size < 1 ) {
>> if ( ptr != NULL ) free(ptr); }
>> else reptr = realloc(ptr,size);
>> return ( reptr ); }
>
> Consider:
>
> return (size == 0) ? free(ptr), NULL : realloc(ptr, size);
>
> which avoids multiple returns, variable assignment, and
> verbiage.

I agree with the general tone of this suggestion. Unfortunately
however the particular code suggested might not compile (because
the macro NULL might be #define'd to be 0, which can result in an
error). Writing the function this way:

void *
realloc0( void *p, size_t size ){
return size == 0 ? free( p ), p = 0 : realloc( p, size );
}

is an easy way to avoid that implementation dependency.

(Some people may prefer writing 'p = NULL' after the call to
free(); my preference in this case is to write 'p = 0', as
shown. But that question is orthogonal to the main point about
avoiding the potential compilation error.)

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u0uk66$1or41$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Sun, 9 Apr 2023 17:04:38 +0200
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <u0uk66$1or41$1@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk>
<u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk>
<u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me>
<u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 9 Apr 2023 15:04:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="498b8d4fc624bb32125a8b5e670c5911";
logging-data="1862785"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kt2kHw6n1WKUKJHYEN092"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.16
Cancel-Lock: sha1:mRUzmFEwbN4UGEq2N2FIvx8jtxg=
In-Reply-To: <86r0st3zj0.fsf@linuxsc.com>
 by: jak - Sun, 9 Apr 2023 15:04 UTC

Tim Rentsch ha scritto:
> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>
> [miscellaneous suggestions taken out]
>
>> On 2023-04-06, John Forkosh <forkosh@panix.com> wrote:
>>
>>> void *realloc0 ( void *ptr, size_t size ) {
>>> void *reptr = NULL;
>>> if ( size < 1 ) {
>>> if ( ptr != NULL ) free(ptr); }
>>> else reptr = realloc(ptr,size);
>>> return ( reptr ); }
>>
>> Consider:
>>
>> return (size == 0) ? free(ptr), NULL : realloc(ptr, size);
>>
>> which avoids multiple returns, variable assignment, and
>> verbiage.
>
> I agree with the general tone of this suggestion. Unfortunately
> however the particular code suggested might not compile (because
> the macro NULL might be #define'd to be 0, which can result in an
> error). Writing the function this way:
>
> void *
> realloc0( void *p, size_t size ){
> return size == 0 ? free( p ), p = 0 : realloc( p, size );
> }
>
> is an easy way to avoid that implementation dependency.
>

If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
on autocast and use an explicit one instead.

>
> (Some people may prefer writing 'p = NULL' after the call to
> free(); my preference in this case is to write 'p = 0', as
> shown. But that question is orthogonal to the main point about
> avoiding the potential compilation error.)
>

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<877cuk3luf.fsf@bsb.me.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan
Date: Sun, 09 Apr 2023 20:19:04 +0100
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <877cuk3luf.fsf@bsb.me.uk>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk>
<u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk>
<u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me>
<u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2c2e5bb3d85ba731d064521f1e2b64f9";
logging-data="1935924"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ZJpaWFq/Rwxt19IeVgTe/jYfrR5a5yS0="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:OS1sB+3SZMa5NjKzQLa7ykj2jr8=
sha1:sw4l59ZdUsy/xJ6WYLjd0NRpFUM=
X-BSB-Auth: 1.fddfe08ebea96701b0fe.20230409201904BST.877cuk3luf.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 9 Apr 2023 19:19 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:

> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>
> [miscellaneous suggestions taken out]
>
>> On 2023-04-06, John Forkosh <forkosh@panix.com> wrote:
>>
>>> void *realloc0 ( void *ptr, size_t size ) {
>>> void *reptr = NULL;
>>> if ( size < 1 ) {
>>> if ( ptr != NULL ) free(ptr); }
>>> else reptr = realloc(ptr,size);
>>> return ( reptr ); }
>>
>> Consider:
>>
>> return (size == 0) ? free(ptr), NULL : realloc(ptr, size);
>>
>> which avoids multiple returns, variable assignment, and
>> verbiage.
>
> I agree with the general tone of this suggestion. Unfortunately
> however the particular code suggested might not compile (because
> the macro NULL might be #define'd to be 0, which can result in an
> error).

I'm not sure what you mean. "Can result in an error" sounds a bit
vague. I know from

> ... the main point about
> avoiding the potential compilation error ...

that you mean a compilation error, but that's not a standard term.

--
Ben.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u0v3vh$df3$1@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Sun, 9 Apr 2023 19:34:09 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u0v3vh$df3$1@reader2.panix.com>
References: <u0fn0g$34scf$1@dont-email.me> <20230407042121.909@kylheku.com> <86r0st3zj0.fsf@linuxsc.com> <u0uk66$1or41$1@dont-email.me>
Injection-Date: Sun, 9 Apr 2023 19:34:09 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="13795"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Sun, 9 Apr 2023 19:34 UTC

In article <u0uk66$1or41$1@dont-email.me>, jak <nospam@please.ty> wrote:
>Tim Rentsch ha scritto:
>>[snip]
>> I agree with the general tone of this suggestion. Unfortunately
>> however the particular code suggested might not compile (because
>> the macro NULL might be #define'd to be 0, which can result in an
>> error). Writing the function this way:
>>
>> void *
>> realloc0( void *p, size_t size ){
>> return size == 0 ? free( p ), p = 0 : realloc( p, size );
>> }
>>
>> is an easy way to avoid that implementation dependency.
>
>If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>on autocast and use an explicit one instead.

What "dependency" would that avoid, other than a dependency on
the C standard?

- Dan C.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u0v426$df3$2@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan
Date: Sun, 9 Apr 2023 19:35:34 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u0v426$df3$2@reader2.panix.com>
References: <u0fn0g$34scf$1@dont-email.me> <86cz4i5cn1.fsf@linuxsc.com> <u0me21$n86$1@reader2.panix.com> <86v8i54yk5.fsf@linuxsc.com>
Injection-Date: Sun, 9 Apr 2023 19:35:34 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="13795"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Sun, 9 Apr 2023 19:35 UTC

In article <86v8i54yk5.fsf@linuxsc.com>,
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>I think you misunderstood my comment. I didn't mean to say
>anything about what the authors say about the evolution of
>realloc(). I meant only that the code they gave works just fine
>(not counting the problem when 'sizeof (int) == 1' that Ben B
>pointed out) -- importantly, under the assumptions that the
>authors explicitly stated -- and that they didn't say anything
>about whether the code is portable or well-defined if considered
>outside of those assumptions. The authors may have some opinions
>about whether the code /should/ work in general, but they don't
>make any claims about whether it /does/ work in general, and that
>point is the only one I mean to address.

No, I understood that, but I disagree: I believe that they were
trying to make a more general statement, beyond simply the
circumstances they outlined.

Of course, without asking them, it's difficult to be certain.

- Dan C.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<871qkshmhv.fsf@nosuchdomain.example.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan
Date: Sun, 09 Apr 2023 12:41:16 -0700
Organization: None to speak of
Lines: 14
Message-ID: <871qkshmhv.fsf@nosuchdomain.example.com>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk>
<u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk>
<u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me>
<u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com> <u0uk66$1or41$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="45edcdbc5dcef05e19c78aa749715243";
logging-data="1939490"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1890XoWkc9SWoO0OPk8zvzn"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:/sUly92SmqSmqer6L6FcA0zmMFM=
sha1:YdeqG0evFgSezAkFa2D+PhIGnVM=
 by: Keith Thompson - Sun, 9 Apr 2023 19:41 UTC

jak <nospam@please.ty> writes:
[...]
> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
> on autocast and use an explicit one instead.

I've never seen the term "autocast" before.

A cast is an explicit conversion. A conversion done without a cast is
an implicit conversion. "Autocast" would be a contradiction.

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

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<86mt3g4z8s.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan
Date: Sun, 09 Apr 2023 12:44:19 -0700
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <86mt3g4z8s.fsf@linuxsc.com>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk> <u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk> <u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me> <u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com> <86r0st3zj0.fsf@linuxsc.com> <u0uk66$1or41$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="2b6f87d227a563a0c00d2eacd0f30cf4";
logging-data="1942671"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UYNu35I9j4wY+LJku4OvzsMbHouy69do="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:24kZEZBVs7xT6RX7T/R6qdsF7zw=
sha1:mq3jRg0DxVnRrkEIW6jPvNnY3E4=
 by: Tim Rentsch - Sun, 9 Apr 2023 19:44 UTC

jak <nospam@please.ty> writes:

> Tim Rentsch ha scritto:
>
>> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>>
>> [miscellaneous suggestions taken out]
>>
>>> On 2023-04-06, John Forkosh <forkosh@panix.com> wrote:
>>>
>>>> void *realloc0 ( void *ptr, size_t size ) {
>>>> void *reptr = NULL;
>>>> if ( size < 1 ) {
>>>> if ( ptr != NULL ) free(ptr); }
>>>> else reptr = realloc(ptr,size);
>>>> return ( reptr ); }
>>>
>>> Consider:
>>>
>>> return (size == 0) ? free(ptr), NULL : realloc(ptr, size);
>>>
>>> which avoids multiple returns, variable assignment, and
>>> verbiage.
>>
>> I agree with the general tone of this suggestion. Unfortunately
>> however the particular code suggested might not compile (because
>> the macro NULL might be #define'd to be 0, which can result in an
>> error). Writing the function this way:
>>
>> void *
>> realloc0( void *p, size_t size ){
>> return size == 0 ? free( p ), p = 0 : realloc( p, size );
>> }
>>
>> is an easy way to avoid that implementation dependency.
>
> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
> on autocast and use an explicit one instead.

The re-written code doesn't have any implementation dependency:
it is guaranteed to work in all versions of C back to ANSI C and
even K&R C (except of course K&R C doesn't have void or void *,
(or size_t?) but the conversion of 0 to any pointer type will
work even back in K&R C).

Furthermore writing an explicit cast is almost always a bad idea,
especially in open code. Writing the expression without a cast
gives the compiler a chance to say that the code is wrong, if
indeed wrong it is. No diagnostics plus no use of any symbols
such as NULL that are implementation-defined means the code will
compile successfully everywhere.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<86ile44yqb.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan
Date: Sun, 09 Apr 2023 12:55:24 -0700
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <86ile44yqb.fsf@linuxsc.com>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk> <u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk> <u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me> <u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com> <86r0st3zj0.fsf@linuxsc.com> <877cuk3luf.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="2b6f87d227a563a0c00d2eacd0f30cf4";
logging-data="1945475"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Ng486pSXg/VwXUOVzHxYMtCtYk0kqdmA="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:ZpHrSdbZA1Nx0N95Fn6kXMiU/po=
sha1:rPrvErjEqi27U9TE5u0XjTigWdk=
 by: Tim Rentsch - Sun, 9 Apr 2023 19:55 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>>
>> [miscellaneous suggestions taken out]
>>
>>> On 2023-04-06, John Forkosh <forkosh@panix.com> wrote:
>>>
>>>> void *realloc0 ( void *ptr, size_t size ) {
>>>> void *reptr = NULL;
>>>> if ( size < 1 ) {
>>>> if ( ptr != NULL ) free(ptr); }
>>>> else reptr = realloc(ptr,size);
>>>> return ( reptr ); }
>>>
>>> Consider:
>>>
>>> return (size == 0) ? free(ptr), NULL : realloc(ptr, size);
>>>
>>> which avoids multiple returns, variable assignment, and
>>> verbiage.
>>
>> I agree with the general tone of this suggestion. Unfortunately
>> however the particular code suggested might not compile (because
>> the macro NULL might be #define'd to be 0, which can result in an
>> error).
>
> I'm not sure what you mean. "Can result in an error" sounds a bit
> vague. I know from
>
>> ... the main point about
>> avoiding the potential compilation error ...
>
> that you mean a compilation error, but that's not a standard term.

If NULL is #define'd to be 0, then a diagnostic is required. The
problem can be seen by attempting to compile this version:

void *
realloc0( void *p, size_t size ){
return size == 0 ? free( p ), 0 : realloc( p, size );
}

The presence of a required diagnostic means the compilation can
fail, without needing any other cause. Of course that doesn't
mean a compilation must fail, but it can fail, and will fail
if for example -Werror was used. Does that clarify what I was
trying to get at?

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<87sfd823c1.fsf@bsb.me.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan
Date: Sun, 09 Apr 2023 21:44:14 +0100
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <87sfd823c1.fsf@bsb.me.uk>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk>
<u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk>
<u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me>
<u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com> <877cuk3luf.fsf@bsb.me.uk>
<86ile44yqb.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2c2e5bb3d85ba731d064521f1e2b64f9";
logging-data="1955198"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WuH6cw3dOXd4xGcqgENwsnbSJsCIQ+HU="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:Wfum0ObchcSubeE5IoBVETgqL60=
sha1:rTFMdgO57gUHgDw5+o58FlIwmh0=
X-BSB-Auth: 1.c346ab212b38460f76e1.20230409214414BST.87sfd823c1.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 9 Apr 2023 20:44 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>
>>> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>>>
>>> [miscellaneous suggestions taken out]
>>>
>>>> On 2023-04-06, John Forkosh <forkosh@panix.com> wrote:
>>>>
>>>>> void *realloc0 ( void *ptr, size_t size ) {
>>>>> void *reptr = NULL;
>>>>> if ( size < 1 ) {
>>>>> if ( ptr != NULL ) free(ptr); }
>>>>> else reptr = realloc(ptr,size);
>>>>> return ( reptr ); }
>>>>
>>>> Consider:
>>>>
>>>> return (size == 0) ? free(ptr), NULL : realloc(ptr, size);
>>>>
>>>> which avoids multiple returns, variable assignment, and
>>>> verbiage.
>>>
>>> I agree with the general tone of this suggestion. Unfortunately
>>> however the particular code suggested might not compile (because
>>> the macro NULL might be #define'd to be 0, which can result in an
>>> error).
>>
>> I'm not sure what you mean. "Can result in an error" sounds a bit
>> vague. I know from
>>
>>> ... the main point about
>>> avoiding the potential compilation error ...
>>
>> that you mean a compilation error, but that's not a standard term.
>
> If NULL is #define'd to be 0, then a diagnostic is required. The
> problem can be seen by attempting to compile this version:
>
> void *
> realloc0( void *p, size_t size ){
> return size == 0 ? free( p ), 0 : realloc( p, size );
> }
>
> The presence of a required diagnostic means the compilation can
> fail, without needing any other cause. Of course that doesn't
> mean a compilation must fail, but it can fail, and will fail
> if for example -Werror was used. Does that clarify what I was
> trying to get at?

Yes, thanks. I thought you mean that, but I was not sure. I prefer to
be more explicit and say that such and such violates a constraint, but I
can see some advantage in using more colloquial terms.

--
Ben.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<86edos4fdk.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan
Date: Sun, 09 Apr 2023 19:53:27 -0700
Organization: A noiseless patient Spider
Lines: 78
Message-ID: <86edos4fdk.fsf@linuxsc.com>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk> <u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk> <u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me> <u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com> <86r0st3zj0.fsf@linuxsc.com> <877cuk3luf.fsf@bsb.me.uk> <86ile44yqb.fsf@linuxsc.com> <87sfd823c1.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="87e12d9da9cc6eb8827b9e1397dfe4c2";
logging-data="2150199"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19biIRPc50z0sGCrM3AacrNsCNyW+iUTLI="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:MyFSPNde7XoABsl2berCtHybtss=
sha1:fVPOBqrXrrMs8ZqC+/nToTMuleo=
 by: Tim Rentsch - Mon, 10 Apr 2023 02:53 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>
>>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>>
>>>> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>>>>
>>>> [miscellaneous suggestions taken out]
>>>>
>>>>> On 2023-04-06, John Forkosh <forkosh@panix.com> wrote:
>>>>>
>>>>>> void *realloc0 ( void *ptr, size_t size ) {
>>>>>> void *reptr = NULL;
>>>>>> if ( size < 1 ) {
>>>>>> if ( ptr != NULL ) free(ptr); }
>>>>>> else reptr = realloc(ptr,size);
>>>>>> return ( reptr ); }
>>>>>
>>>>> Consider:
>>>>>
>>>>> return (size == 0) ? free(ptr), NULL : realloc(ptr, size);
>>>>>
>>>>> which avoids multiple returns, variable assignment, and
>>>>> verbiage.
>>>>
>>>> I agree with the general tone of this suggestion. Unfortunately
>>>> however the particular code suggested might not compile (because
>>>> the macro NULL might be #define'd to be 0, which can result in an
>>>> error).
>>>
>>> I'm not sure what you mean. "Can result in an error" sounds a bit
>>> vague. I know from
>>>
>>>> ... the main point about
>>>> avoiding the potential compilation error ...
>>>
>>> that you mean a compilation error, but that's not a standard term.
>>
>> If NULL is #define'd to be 0, then a diagnostic is required. The
>> problem can be seen by attempting to compile this version:
>>
>> void *
>> realloc0( void *p, size_t size ){
>> return size == 0 ? free( p ), 0 : realloc( p, size );
>> }
>>
>> The presence of a required diagnostic means the compilation can
>> fail, without needing any other cause. Of course that doesn't
>> mean a compilation must fail, but it can fail, and will fail
>> if for example -Werror was used. Does that clarify what I was
>> trying to get at?
>
> Yes, thanks. I thought you mean that, but I was not sure. I
> prefer to be more explicit and say that such and such violates a
> constraint, but I can see some advantage in using more colloquial
> terms.

It is often the case that I feel a tension between using formal
phrasing as it is used in the C standard, and informal phrasing
more like common English usage. Personally I think either can be
appropriate, depending on the particular issue being discussed and
on the expected audience. I must admit, however, that frequently
I get push back from one side or the other, carrying at least an
implicit suggestion that I made a bad choice. For the most part I
simply accept these comments as part of the price for trying to
make a reasonable decision in the face of incomplete information
(while still allowing for the possibility that my decisions in the
future may be altered). When reading comments made by other
people, I always try to understand what perspective they are
taking, and adjust my verbal processing accordingly; it is only
when I can't find a way of understanding their comments that I
want to bring it up. What is that aphorism? "Assume that what
they are saying makes sense, and try to find a way of looking at
it so that it's sensible, to understand what they meant." Or
something like that.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u10dvr$23np8$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 09:31:06 +0200
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <u10dvr$23np8$1@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk>
<u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk>
<u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me>
<u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com> <u0uk66$1or41$1@dont-email.me>
<871qkshmhv.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 07:31:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="324c3efb794bc08f3c95a3facab56a11";
logging-data="2219816"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19eBb0lxHaVy0B78tTP0CUy"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.16
Cancel-Lock: sha1:MEZvv2iiEW6CAyPrLqiJ5xp8rmI=
In-Reply-To: <871qkshmhv.fsf@nosuchdomain.example.com>
 by: jak - Mon, 10 Apr 2023 07:31 UTC

Keith Thompson ha scritto:
> jak <nospam@please.ty> writes:
> [...]
>> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>> on autocast and use an explicit one instead.
>
> I've never seen the term "autocast" before.
>
> A cast is an explicit conversion. A conversion done without a cast is
> an implicit conversion. "Autocast" would be a contradiction.
>

Maybe this is because we don't come from the same county and therefore,
probably, haven't read the same books? I don't formalize myself nor am I
shocked when I read 'implicit conversion' despite the cast it should be
considered a stretch and not a conversion. Perhaps you too should have a
more open mind.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u10erc$23rhg$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 09:45:48 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <u10erc$23rhg$1@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com> <u0uk66$1or41$1@dont-email.me>
<u0v3vh$df3$1@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 07:45:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="324c3efb794bc08f3c95a3facab56a11";
logging-data="2223664"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cUUap0yEGSqV3cjWf1BOh"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.16
Cancel-Lock: sha1:M0bsz932netC/993ZwGLvELmCXE=
In-Reply-To: <u0v3vh$df3$1@reader2.panix.com>
 by: jak - Mon, 10 Apr 2023 07:45 UTC

Dan Cross ha scritto:
> In article <u0uk66$1or41$1@dont-email.me>, jak <nospam@please.ty> wrote:
>> Tim Rentsch ha scritto:
>>> [snip]
>>> I agree with the general tone of this suggestion. Unfortunately
>>> however the particular code suggested might not compile (because
>>> the macro NULL might be #define'd to be 0, which can result in an
>>> error). Writing the function this way:
>>>
>>> void *
>>> realloc0( void *p, size_t size ){
>>> return size == 0 ? free( p ), p = 0 : realloc( p, size );
>>> }
>>>
>>> is an easy way to avoid that implementation dependency.
>>
>> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>> on autocast and use an explicit one instead.
>
> What "dependency" would that avoid, other than a dependency on
> the C standard?
>
> - Dan C.
>
Why are you asking me this? Perhaps you consider being portability if
you move the source code to another machine with the same operating
system, same compiler, same compiler version.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u11404$26gpq$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 09:46:43 -0400
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <u11404$26gpq$1@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk>
<u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk>
<u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me>
<u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com> <u0uk66$1or41$1@dont-email.me>
<871qkshmhv.fsf@nosuchdomain.example.com> <u10dvr$23np8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 13:46:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="585a2b92344e96b538cef7b9f0a43c30";
logging-data="2310970"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ErRdHME84ORGXc+W1laylSBSOKAfetxs="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:C71LiTiyhQra6TrW1U73iK/X060=
In-Reply-To: <u10dvr$23np8$1@dont-email.me>
Content-Language: en-US
 by: James Kuyper - Mon, 10 Apr 2023 13:46 UTC

On 4/10/23 03:31, jak wrote:
> Keith Thompson ha scritto:
>> jak <nospam@please.ty> writes:
>> [...]
>>> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>>> on autocast and use an explicit one instead.
>>
>> I've never seen the term "autocast" before.
>>
>> A cast is an explicit conversion. A conversion done without a cast is
>> an implicit conversion. "Autocast" would be a contradiction.
>>
>
> Maybe this is because we don't come from the same county and therefore,
> probably, haven't read the same books? I don't formalize myself nor am I
> shocked when I read 'implicit conversion' despite the cast it should be
> considered a stretch and not a conversion. Perhaps you too should have a
> more open mind.

The C standard is a semi-formal document, and defines the meanings of
many terms used in that document, meanings that are almost always at
least subtly (and often not so subtly) different from the normal meaning
of the English words that they are built from. The meanings defined by
the standard are the ones that apply when interpreting what the standard
means. It is correspondingly important to know what those meanings are.

The word "stretch" appears nowhere in the C standard. As a very
well-read native speaker of English with a very good understanding of C,
and a fairly good understanding of most programming jargon, I'm not sure
what you mean by "stretch". None of the 10 meanings listed at
wiktionary.org for "stretch" seems applicable.
Would you care to describe what you mean by that term, and how it
differs from a conversion? I haven't a clue.

"Several operators convert operand values from one type to another
automatically. This subclause specifies the result required from such an
implicit conversion, as well as those that result from a cast
operation (an explicit conversion)." (6.3p1)

The terms "implicit conversion" and "explicit conversion" are both
italicized in the actual standard, which is an ISO convention indicating
that the sentence in which they occur is the official definition of what
those terms mean.

Implicit conversions occur in the following contexts:

The integer promotions (6.3.1.1p2).
The usual arithmetic conversions (6.3.1.8p1).

An lvalue of array type is implicitly converted into a pointer to the
first element of that array in many contexts (6.3.2p3). This is done as
a convenience, but has led many people to confuse arrays with pointers.

A function designator is implicitly converted into a pointer to the
designated function in many contexts (6.3.2p4).

The default argument promotions (6.5.2.2p6).

Simple assignment (6.5.16.1p2).

As-if by assignment:
Arguments of function declared with a prototype. (6.5.2.2p7, 6.9.1p10)
Return expression. (6.8.6.4p3)

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u116a4$270uv$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 10:26:01 -0400
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <u116a4$270uv$1@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com> <u0uk66$1or41$1@dont-email.me>
<u0v3vh$df3$1@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 14:26:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="585a2b92344e96b538cef7b9f0a43c30";
logging-data="2327519"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19H+ftPuW1Sypn0q06LiLsKeaK30qalO+s="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:LEaSqUiuV79oWiIZlfnFJTkFNBE=
Content-Language: en-US
In-Reply-To: <u0v3vh$df3$1@reader2.panix.com>
 by: James Kuyper - Mon, 10 Apr 2023 14:26 UTC

On 4/9/23 15:34, Dan Cross wrote:
> In article <u0uk66$1or41$1@dont-email.me>, jak <nospam@please.ty> wrote:
>> Tim Rentsch ha scritto:
>>> [snip]
>>> I agree with the general tone of this suggestion. Unfortunately
>>> however the particular code suggested might not compile (because
>>> the macro NULL might be #define'd to be 0, which can result in an
>>> error). Writing the function this way:
>>>
>>> void *
>>> realloc0( void *p, size_t size ){
>>> return size == 0 ? free( p ), p = 0 : realloc( p, size );
>>> }
>>>
>>> is an easy way to avoid that implementation dependency.
>>
>> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>> on autocast and use an explicit one instead.
>
> What "dependency" would that avoid, other than a dependency on
> the C standard?

The C standard merely requires that NULL expand to a null pointer
constant. It depends upon the implementation which null pointer constant
it expands to. A null pointer constant necessarily has either an integer
type or the type void*. The comma expression will have that same type.
An integer type results in a constraint violation, void* does not.
That's the implementation dependency that Tim was talking about.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u116gd$273m1$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 16:29:33 +0200
Organization: A noiseless patient Spider
Lines: 71
Message-ID: <u116gd$273m1$1@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk>
<u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk>
<u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me>
<u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com> <u0uk66$1or41$1@dont-email.me>
<871qkshmhv.fsf@nosuchdomain.example.com> <u10dvr$23np8$1@dont-email.me>
<u11404$26gpq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 14:29:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="324c3efb794bc08f3c95a3facab56a11";
logging-data="2330305"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/ESQ0yPGc8PkIbuVA/dFI"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.16
Cancel-Lock: sha1:DZA9E2gqef41MkBM9JpkTcPjVzU=
In-Reply-To: <u11404$26gpq$1@dont-email.me>
 by: jak - Mon, 10 Apr 2023 14:29 UTC

James Kuyper ha scritto:
> On 4/10/23 03:31, jak wrote:
>> Keith Thompson ha scritto:
>>> jak <nospam@please.ty> writes:
>>> [...]
>>>> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>>>> on autocast and use an explicit one instead.
>>>
>>> I've never seen the term "autocast" before.
>>>
>>> A cast is an explicit conversion. A conversion done without a cast is
>>> an implicit conversion. "Autocast" would be a contradiction.
>>>
>>
>> Maybe this is because we don't come from the same county and therefore,
>> probably, haven't read the same books? I don't formalize myself nor am I
>> shocked when I read 'implicit conversion' despite the cast it should be
>> considered a stretch and not a conversion. Perhaps you too should have a
>> more open mind.
>
> The C standard is a semi-formal document, and defines the meanings of
> many terms used in that document, meanings that are almost always at
> least subtly (and often not so subtly) different from the normal meaning
> of the English words that they are built from. The meanings defined by
> the standard are the ones that apply when interpreting what the standard
> means. It is correspondingly important to know what those meanings are.
>
> The word "stretch" appears nowhere in the C standard. As a very
> well-read native speaker of English with a very good understanding of C,
> and a fairly good understanding of most programming jargon, I'm not sure
> what you mean by "stretch". None of the 10 meanings listed at
> wiktionary.org for "stretch" seems applicable.
> Would you care to describe what you mean by that term, and how it
> differs from a conversion? I haven't a clue.
>
> "Several operators convert operand values from one type to another
> automatically. This subclause specifies the result required from such an
> implicit conversion, as well as those that result from a cast
> operation (an explicit conversion)." (6.3p1)
>
> The terms "implicit conversion" and "explicit conversion" are both
> italicized in the actual standard, which is an ISO convention indicating
> that the sentence in which they occur is the official definition of what
> those terms mean.
>
> Implicit conversions occur in the following contexts:
>
> The integer promotions (6.3.1.1p2).
> The usual arithmetic conversions (6.3.1.8p1).
>
> An lvalue of array type is implicitly converted into a pointer to the
> first element of that array in many contexts (6.3.2p3). This is done as
> a convenience, but has led many people to confuse arrays with pointers.
>
> A function designator is implicitly converted into a pointer to the
> designated function in many contexts (6.3.2p4).
>
> The default argument promotions (6.5.2.2p6).
>
> Simple assignment (6.5.16.1p2).
>
> As-if by assignment:
> Arguments of function declared with a prototype. (6.5.2.2p7, 6.9.1p10)
> Return expression. (6.8.6.4p3)
>
>
Are you K.T's knight perhaps? Please stop quoting bits of manuals that
everyone has read hundreds of times, be less obtuse and learn to read
what is not written. Some field work wouldn't hurt. Do not hoe but claim
to design hoes.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u116uf$275ph$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 16:37:03 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <u116uf$275ph$1@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk>
<u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk>
<u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me>
<u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com> <u0uk66$1or41$1@dont-email.me>
<871qkshmhv.fsf@nosuchdomain.example.com> <u10dvr$23np8$1@dont-email.me>
<u11404$26gpq$1@dont-email.me> <u116gd$273m1$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 14:37:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="324c3efb794bc08f3c95a3facab56a11";
logging-data="2332465"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vBqnY8KESFIEPbRcphJSG"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.16
Cancel-Lock: sha1:+eU2Vkp5IJUWsuSiKrIl0f9PP1k=
In-Reply-To: <u116gd$273m1$1@dont-email.me>
 by: jak - Mon, 10 Apr 2023 14:37 UTC

>>
> Are you K.T's knight perhaps? Please stop quoting bits of manuals that
> everyone has read hundreds of times, be less obtuse and learn to read
> what is not written. Some field work wouldn't hurt. Do not hoe but claim
> to design hoes.
> Instead, explain to me why, after all the improvements introduced by the
standards, it is no longer possible to declare a specialized function
pointer array without first declaring the typedef that defines the
function pointer and why.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u117os$9r2$1@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 14:51:08 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u117os$9r2$1@reader2.panix.com>
References: <u0fn0g$34scf$1@dont-email.me> <u0uk66$1or41$1@dont-email.me> <u0v3vh$df3$1@reader2.panix.com> <u116a4$270uv$1@dont-email.me>
Injection-Date: Mon, 10 Apr 2023 14:51:08 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="10082"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Mon, 10 Apr 2023 14:51 UTC

In article <u116a4$270uv$1@dont-email.me>,
James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>On 4/9/23 15:34, Dan Cross wrote:
>> In article <u0uk66$1or41$1@dont-email.me>, jak <nospam@please.ty> wrote:
>>> Tim Rentsch ha scritto:
>>>> [snip]
>>>> I agree with the general tone of this suggestion. Unfortunately
>>>> however the particular code suggested might not compile (because
>>>> the macro NULL might be #define'd to be 0, which can result in an
>>>> error). Writing the function this way:
>>>>
>>>> void *
>>>> realloc0( void *p, size_t size ){
>>>> return size == 0 ? free( p ), p = 0 : realloc( p, size );
>>>> }
>>>>
>>>> is an easy way to avoid that implementation dependency.
>>>
>>> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>>> on autocast and use an explicit one instead.
>>
>> What "dependency" would that avoid, other than a dependency on
>> the C standard?
>
>The C standard merely requires that NULL expand to a null pointer
>constant. It depends upon the implementation which null pointer constant
>it expands to. A null pointer constant necessarily has either an integer
>type or the type void*. The comma expression will have that same type.
>An integer type results in a constraint violation, void* does not.
>That's the implementation dependency that Tim was talking about.

The C standard has been quite explicit that integer 0 is
a valid null pointer constant since C89. Tim's code was
correct and had no dependency.

- Dan C.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u117rb$9r2$2@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 14:52:27 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u117rb$9r2$2@reader2.panix.com>
References: <u0fn0g$34scf$1@dont-email.me> <u0uk66$1or41$1@dont-email.me> <u0v3vh$df3$1@reader2.panix.com> <u10erc$23rhg$1@dont-email.me>
Injection-Date: Mon, 10 Apr 2023 14:52:27 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="10082"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Mon, 10 Apr 2023 14:52 UTC

In article <u10erc$23rhg$1@dont-email.me>, jak <nospam@please.ty> wrote:
>Dan Cross ha scritto:
>> In article <u0uk66$1or41$1@dont-email.me>, jak <nospam@please.ty> wrote:
>>> Tim Rentsch ha scritto:
>>>> [snip]
>>>> I agree with the general tone of this suggestion. Unfortunately
>>>> however the particular code suggested might not compile (because
>>>> the macro NULL might be #define'd to be 0, which can result in an
>>>> error). Writing the function this way:
>>>>
>>>> void *
>>>> realloc0( void *p, size_t size ){
>>>> return size == 0 ? free( p ), p = 0 : realloc( p, size );
>>>> }
>>>>
>>>> is an easy way to avoid that implementation dependency.
>>>
>>> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>>> on autocast and use an explicit one instead.
>>
>> What "dependency" would that avoid, other than a dependency on
>> the C standard?
>
>Why are you asking me this?

Because you are the one who suggested there is some kind of
"dependency" in Tim's code?

>Perhaps you consider being portability if
>you move the source code to another machine with the same operating
>system, same compiler, same compiler version.

This has nothing to do with that. Tim's code was correct and
portable.

- Dan C.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u119gi$27go7$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 11:20:50 -0400
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <u119gi$27go7$1@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <u0uk66$1or41$1@dont-email.me>
<u0v3vh$df3$1@reader2.panix.com> <u116a4$270uv$1@dont-email.me>
<u117os$9r2$1@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 10 Apr 2023 15:20:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="585a2b92344e96b538cef7b9f0a43c30";
logging-data="2343687"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+S45vAoEM1UYAkXsu27iBqgyDOA3Qiyew="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:GAdD7kgB4Z+h3NanbAWCBIsmb5k=
Content-Language: en-US
In-Reply-To: <u117os$9r2$1@reader2.panix.com>
 by: James Kuyper - Mon, 10 Apr 2023 15:20 UTC

On 4/10/23 10:51, Dan Cross wrote:
> In article <u116a4$270uv$1@dont-email.me>,
> James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>> On 4/9/23 15:34, Dan Cross wrote:
>>> In article <u0uk66$1or41$1@dont-email.me>, jak <nospam@please.ty> wrote:
>>>> Tim Rentsch ha scritto:
>>>>> [snip]
>>>>> I agree with the general tone of this suggestion. Unfortunately
>>>>> however the particular code suggested might not compile (because
>>>>> the macro NULL might be #define'd to be 0, which can result in an
>>>>> error). Writing the function this way:
>>>>>
>>>>> void *
>>>>> realloc0( void *p, size_t size ){
>>>>> return size == 0 ? free( p ), p = 0 : realloc( p, size );
>>>>> }
>>>>>
>>>>> is an easy way to avoid that implementation dependency.
>>>>
>>>> If you absolutely wanted to avoid dependency, perhaps you shouldn't
>>>> rely
>>>> on autocast and use an explicit one instead.
>>>
>>> What "dependency" would that avoid, other than a dependency on
>>> the C standard?
>>
>> The C standard merely requires that NULL expand to a null pointer
>> constant. It depends upon the implementation which null pointer constant
>> it expands to. A null pointer constant necessarily has either an integer
>> type or the type void*. The comma expression will have that same type.
>> An integer type results in a constraint violation, void* does not.
>> That's the implementation dependency that Tim was talking about.
>
> The C standard has been quite explicit that integer 0 is
> a valid null pointer constant since C89. Tim's code was
> correct and had no dependency.

Correct. 0 is a valid null pointer constant. It has a type of int.
Therefore, the expression "free(p), 0' would have a value of 0 and a
type of int. The expression 'size == 0 ? NULL : realloc(p, size)" would
not be problematic because, in that context, a null pointer constant
gets implicitly converted to a null pointer with the same type as the
return value of realloc (6.5.15p7). However, function calls are not
allowed in integer constant expressions (6.6p6), so "free(p), 0" does
NOT qualify as an integer constant expression, and therefore also does
not qualify as a null pointer constant (6.3.2.3p3). A conditional
expression where the second operand has an arithmetic type, but does not
qualify as a null pointer constant, and a third operand that has pointer
type, doesn't match any of the permitted combinations listed in the
constraints on conditional expressions (6.5.15p3):

"One of the following shall hold for the second and third operands:
ISO/IEC 9899:202x (E)
— both operands have arithmetic type;
— both operands have the same structure or union type;
— both operands have void type;
— both operands are pointers to qualified or unqualified versions of
compatible types;
— one operand is a pointer and the other is a null pointer constant; or
— one operand is a pointer to an object type and the other is a pointer
to a qualified or unqualified
version of void ."

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u119hk$27go7$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 11:21:24 -0400
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <u119hk$27go7$2@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk>
<u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk>
<u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me>
<u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com> <u0uk66$1or41$1@dont-email.me>
<871qkshmhv.fsf@nosuchdomain.example.com> <u10dvr$23np8$1@dont-email.me>
<u11404$26gpq$1@dont-email.me> <u116gd$273m1$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 15:21:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="585a2b92344e96b538cef7b9f0a43c30";
logging-data="2343687"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ULU28UqP0RPgr7l118J5NXJji9vIhpnk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:kqcifppeOkxr9hBR11HHk2EtlHc=
Content-Language: en-US
In-Reply-To: <u116gd$273m1$1@dont-email.me>
 by: James Kuyper - Mon, 10 Apr 2023 15:21 UTC

On 4/10/23 10:29, jak wrote:
> James Kuyper ha scritto:
>> On 4/10/23 03:31, jak wrote:
>>> Keith Thompson ha scritto:
>>>> jak <nospam@please.ty> writes:
>>>> [...]
>>>>> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>>>>> on autocast and use an explicit one instead.
>>>>
>>>> I've never seen the term "autocast" before.
>>>>
>>>> A cast is an explicit conversion. A conversion done without a cast is
>>>> an implicit conversion. "Autocast" would be a contradiction.
>>>>
>>>
>>> Maybe this is because we don't come from the same county and therefore,
>>> probably, haven't read the same books? I don't formalize myself nor am I
>>> shocked when I read 'implicit conversion' despite the cast it should be
>>> considered a stretch and not a conversion. Perhaps you too should have a
>>> more open mind.
....
>> The word "stretch" appears nowhere in the C standard. As a very
>> well-read native speaker of English with a very good understanding of C,
>> and a fairly good understanding of most programming jargon, I'm not sure
>> what you mean by "stretch". None of the 10 meanings listed at
>> wiktionary.org for "stretch" seems applicable.
>> Would you care to describe what you mean by that term, and how it
>> differs from a conversion? I haven't a clue.
....
> Are you K.T's knight perhaps? Please stop quoting bits of manuals that
> everyone has read hundreds of times, be less obtuse and learn to read
> what is not written. Some field work wouldn't hurt. Do not hoe but claim
> to design hoes.

Are you referring to Keith Thompson? I am not his knight, whatever you
might mean by that; we're just two people with similar attitudes about
formal rigor, and as a result are often (but not always) in agreement
about what the standard means.
The standard is not a manual. I seriously doubt that you have read it
hundreds of times.
I remain unenlightened as to what "stretch" might mean in this context.
I can't even imagine where I might look for a definition.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u119q9$27go7$3@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 11:26:01 -0400
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <u119q9$27go7$3@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <87zg7n89zw.fsf@bsb.me.uk>
<u0ig61$64g$1@reader2.panix.com> <874jpv84uv.fsf@bsb.me.uk>
<u0jt3l$cmu$1@reader2.panix.com> <u0k3au$3uelq$1@dont-email.me>
<u0lm3j$8iu$1@reader2.panix.com> <20230407042121.909@kylheku.com>
<86r0st3zj0.fsf@linuxsc.com> <u0uk66$1or41$1@dont-email.me>
<871qkshmhv.fsf@nosuchdomain.example.com> <u10dvr$23np8$1@dont-email.me>
<u11404$26gpq$1@dont-email.me> <u116gd$273m1$1@dont-email.me>
<u116uf$275ph$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 15:26:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="585a2b92344e96b538cef7b9f0a43c30";
logging-data="2343687"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/d1TO/3Z+GYzbBahC972iFRH6o6Y+Ma00="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:eIYUfDHAE4BLp/za0GCpkNZuDAU=
In-Reply-To: <u116uf$275ph$1@dont-email.me>
Content-Language: en-US
 by: James Kuyper - Mon, 10 Apr 2023 15:26 UTC

On 4/10/23 10:37, jak wrote:
....
>> Instead, explain to me why, after all the improvements introduced by the
> standards, it is no longer possible to declare a specialized function
> pointer array without first declaring the typedef that defines the
> function pointer and why.

"specialized function pointer array"? Are you posting that to the
correct newsgroup?
Even if this were comp.lang.c++, you've just swerved off into an
entirely different conversational direction - I would recommend starting
a new thread to discuss that issue.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u11a0u$27j9d$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 17:29:33 +0200
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <u11a0u$27j9d$1@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <u0uk66$1or41$1@dont-email.me>
<u0v3vh$df3$1@reader2.panix.com> <u10erc$23rhg$1@dont-email.me>
<u117rb$9r2$2@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 15:29:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="324c3efb794bc08f3c95a3facab56a11";
logging-data="2346285"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1ot+4P1SIGLfiILjo5xfw"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.16
Cancel-Lock: sha1:5sxn6khcwGdmAUFSQV5wQnET4mU=
In-Reply-To: <u117rb$9r2$2@reader2.panix.com>
 by: jak - Mon, 10 Apr 2023 15:29 UTC

Dan Cross ha scritto:
> In article <u10erc$23rhg$1@dont-email.me>, jak <nospam@please.ty> wrote:
>> Dan Cross ha scritto:
>>> In article <u0uk66$1or41$1@dont-email.me>, jak <nospam@please.ty> wrote:
>>>> Tim Rentsch ha scritto:
>>>>> [snip]
>>>>> I agree with the general tone of this suggestion. Unfortunately
>>>>> however the particular code suggested might not compile (because
>>>>> the macro NULL might be #define'd to be 0, which can result in an
>>>>> error). Writing the function this way:
>>>>>
>>>>> void *
>>>>> realloc0( void *p, size_t size ){
>>>>> return size == 0 ? free( p ), p = 0 : realloc( p, size );
>>>>> }
>>>>>
>>>>> is an easy way to avoid that implementation dependency.
>>>>
>>>> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>>>> on autocast and use an explicit one instead.
>>>
>>> What "dependency" would that avoid, other than a dependency on
>>> the C standard?
>>
>> Why are you asking me this?
>
> Because you are the one who suggested there is some kind of
> "dependency" in Tim's code?
>
>> Perhaps you consider being portability if
>> you move the source code to another machine with the same operating
>> system, same compiler, same compiler version.
>
> This has nothing to do with that. Tim's code was correct and
> portable.
>
> - Dan C.
>
Correct for sure but you and I don't have the same concept of portable.
There are compilers that don't accept things like this:

char val;
int *pi;

pi = (int *)&val;

because if you assigned a value to *pi you would be using unallocated
memory and if you really want to do that you need a left cast:

((char *)pi) = &val;

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u11aau$27go8$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 11:34:54 -0400
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <u11aau$27go8$1@dont-email.me>
References: <u0fn0g$34scf$1@dont-email.me> <u0uk66$1or41$1@dont-email.me>
<u0v3vh$df3$1@reader2.panix.com> <u10erc$23rhg$1@dont-email.me>
<u117rb$9r2$2@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Apr 2023 15:34:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="585a2b92344e96b538cef7b9f0a43c30";
logging-data="2343688"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Wl2hnVLaOIxvCCIC6vROr6YpX7mAAE38="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:x/POaEiIvpHbnIt5//cQsfXaEZ4=
In-Reply-To: <u117rb$9r2$2@reader2.panix.com>
Content-Language: en-US
 by: James Kuyper - Mon, 10 Apr 2023 15:34 UTC

On 4/10/23 10:52, Dan Cross wrote:
> In article <u10erc$23rhg$1@dont-email.me>, jak <nospam@please.ty> wrote:
>> Dan Cross ha scritto:
>>> In article <u0uk66$1or41$1@dont-email.me>, jak <nospam@please.ty> wrote:
>>>> Tim Rentsch ha scritto:
>>>>> [snip]
>>>>> I agree with the general tone of this suggestion. Unfortunately
>>>>> however the particular code suggested might not compile (because
>>>>> the macro NULL might be #define'd to be 0, which can result in an
>>>>> error). Writing the function this way:
>>>>>
>>>>> void *
>>>>> realloc0( void *p, size_t size ){
>>>>> return size == 0 ? free( p ), p = 0 : realloc( p, size );
>>>>> }
>>>>>
>>>>> is an easy way to avoid that implementation dependency.
>>>>
>>>> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>>>> on autocast and use an explicit one instead.
>>>
>>> What "dependency" would that avoid, other than a dependency on
>>> the C standard?
>>
>> Why are you asking me this?
>
> Because you are the one who suggested there is some kind of
> "dependency" in Tim's code?

The comment about "implementation dependency" was written by Tim, jak
was merely referring to that comment.

>> Perhaps you consider being portability if
>> you move the source code to another machine with the same operating
>> system, same compiler, same compiler version.
>
> This has nothing to do with that. Tim's code was correct and
> portable.

Tim's comment about an implementation dependency was written about code
written by Kaz Kylheku. That code does indeed have an implementation
dependency. Depending upon which choice an implementation makes for the
null pointer constant that NULL expands into, Kaz's code might or might
not contain a constraint violation.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u11aba$1jl$1@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 15:35:06 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u11aba$1jl$1@reader2.panix.com>
References: <u0fn0g$34scf$1@dont-email.me> <u116a4$270uv$1@dont-email.me> <u117os$9r2$1@reader2.panix.com> <u119gi$27go7$1@dont-email.me>
Injection-Date: Mon, 10 Apr 2023 15:35:06 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="1653"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Mon, 10 Apr 2023 15:35 UTC

In article <u119gi$27go7$1@dont-email.me>,
James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>On 4/10/23 10:51, Dan Cross wrote:
>> In article <u116a4$270uv$1@dont-email.me>,
>> James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>>> On 4/9/23 15:34, Dan Cross wrote:
>>>> In article <u0uk66$1or41$1@dont-email.me>, jak <nospam@please.ty> wrote:
>>>>> Tim Rentsch ha scritto:
>>>>>> [snip]
>>>>>> I agree with the general tone of this suggestion. Unfortunately
>>>>>> however the particular code suggested might not compile (because
>>>>>> the macro NULL might be #define'd to be 0, which can result in an
>>>>>> error). Writing the function this way:
>>>>>>
>>>>>> void *
>>>>>> realloc0( void *p, size_t size ){
>>>>>> return size == 0 ? free( p ), p = 0 : realloc( p, size );
>>>>>> }
>>>>>>
>>>>>> is an easy way to avoid that implementation dependency.
>>>>>
>>>>> If you absolutely wanted to avoid dependency, perhaps you shouldn't
>>>>> rely
>>>>> on autocast and use an explicit one instead.
>>>>
>>>> What "dependency" would that avoid, other than a dependency on
>>>> the C standard?
>>>
>>> The C standard merely requires that NULL expand to a null pointer
>>> constant. It depends upon the implementation which null pointer constant
>>> it expands to. A null pointer constant necessarily has either an integer
>>> type or the type void*. The comma expression will have that same type.
>>> An integer type results in a constraint violation, void* does not.
>>> That's the implementation dependency that Tim was talking about.
>>
>> The C standard has been quite explicit that integer 0 is
>> a valid null pointer constant since C89. Tim's code was
>> correct and had no dependency.
>
>Correct. 0 is a valid null pointer constant. It has a type of int.
>Therefore, the expression "free(p), 0' would have a value of 0 and a
>type of int. The expression 'size == 0 ? NULL : realloc(p, size)" would
>not be problematic because, in that context, a null pointer constant
>gets implicitly converted to a null pointer with the same type as the
>return value of realloc (6.5.15p7). However, function calls are not
>allowed in integer constant expressions (6.6p6), so "free(p), 0" does
>NOT qualify as an integer constant expression, and therefore also does
>not qualify as a null pointer constant (6.3.2.3p3). A conditional
>expression where the second operand has an arithmetic type, but does not
>qualify as a null pointer constant, and a third operand that has pointer
>type, doesn't match any of the permitted combinations listed in the
>constraints on conditional expressions (6.5.15p3):
>
>"One of the following shall hold for the second and third operands:
>ISO/IEC 9899:202x (E)
>— both operands have arithmetic type;
>— both operands have the same structure or union type;
>— both operands have void type;
>— both operands are pointers to qualified or unqualified versions of
>compatible types;
>— one operand is a pointer and the other is a null pointer constant; or
>— one operand is a pointer to an object type and the other is a pointer
>to a qualified or unqualified
>version of void ."

I do not know why you are addressing this to me. I agreed with
the overall analysis and don't think I posted anything to the
contrary.

Perhaps you meant to respond to someone else?

- Dan C.

Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

<u11afa$1jl$2@reader2.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence
Kelly with Special Guest Borer Yekai Pan
Date: Mon, 10 Apr 2023 15:37:14 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <u11afa$1jl$2@reader2.panix.com>
References: <u0fn0g$34scf$1@dont-email.me> <u10erc$23rhg$1@dont-email.me> <u117rb$9r2$2@reader2.panix.com> <u11aau$27go8$1@dont-email.me>
Injection-Date: Mon, 10 Apr 2023 15:37:14 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="1653"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Mon, 10 Apr 2023 15:37 UTC

In article <u11aau$27go8$1@dont-email.me>,
James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>On 4/10/23 10:52, Dan Cross wrote:
>> In article <u10erc$23rhg$1@dont-email.me>, jak <nospam@please.ty> wrote:
>>> Dan Cross ha scritto:
>>>> In article <u0uk66$1or41$1@dont-email.me>, jak <nospam@please.ty> wrote:
>>>>> Tim Rentsch ha scritto:
>>>>>> [snip]
>>>>>> I agree with the general tone of this suggestion. Unfortunately
>>>>>> however the particular code suggested might not compile (because
>>>>>> the macro NULL might be #define'd to be 0, which can result in an
>>>>>> error). Writing the function this way:
>>>>>>
>>>>>> void *
>>>>>> realloc0( void *p, size_t size ){
>>>>>> return size == 0 ? free( p ), p = 0 : realloc( p, size );
>>>>>> }
>>>>>>
>>>>>> is an easy way to avoid that implementation dependency.
>>>>>
>>>>> If you absolutely wanted to avoid dependency, perhaps you shouldn't rely
>>>>> on autocast and use an explicit one instead.
>>>>
>>>> What "dependency" would that avoid, other than a dependency on
>>>> the C standard?
>>>
>>> Why are you asking me this?
>>
>> Because you are the one who suggested there is some kind of
>> "dependency" in Tim's code?
>
>The comment about "implementation dependency" was written by Tim, jak
>was merely referring to that comment.

It seemed that jak was suggesting that in Tim's forumulation,
one should cast the 0 in p = 0, as in `p = (void *)0`.

>>> Perhaps you consider being portability if
>>> you move the source code to another machine with the same operating
>>> system, same compiler, same compiler version.
>>
>> This has nothing to do with that. Tim's code was correct and
>> portable.
>
>Tim's comment about an implementation dependency was written about code
>written by Kaz Kylheku. That code does indeed have an implementation
>dependency. Depending upon which choice an implementation makes for the
>null pointer constant that NULL expands into, Kaz's code might or might
>not contain a constraint violation.

That was not what I was referring to; see above and please note
the exact words I responded to (specifically the post that
referred to "autocast").

- Dan C.


devel / comp.lang.c / Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan

Pages:12345678
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor