Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

All syllogisms have three parts, therefore this is not a syllogism.


devel / comp.lang.c / Sequencing guarantees for macro versions of standard functions

SubjectAuthor
* Sequencing guarantees for macro versions of standard functionsAndrey Tarasevich
`* Re: Sequencing guarantees for macro versions of standard functionsTim Rentsch
 `* Re: Sequencing guarantees for macro versions of standard functionsKeith Thompson
  `* Re: Sequencing guarantees for macro versions of standard functionsTim Rentsch
   +* Re: Sequencing guarantees for macro versions of standard functionsAndrey Tarasevich
   |`* Re: Sequencing guarantees for macro versions of standard functionsAndrey Tarasevich
   | +- Re: Sequencing guarantees for macro versions of standard functionsKeith Thompson
   | `- Re: Sequencing guarantees for macro versions of standard functionsTim Rentsch
   `* Re: Sequencing guarantees for macro versions of standard functionsKeith Thompson
    `* Re: Sequencing guarantees for macro versions of standard functionsTim Rentsch
     `* Re: Sequencing guarantees for macro versions of standard functionsKeith Thompson
      `- Re: Sequencing guarantees for macro versions of standard functionsTim Rentsch

1
Sequencing guarantees for macro versions of standard functions

<ssct1k$651$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c
Subject: Sequencing guarantees for macro versions of standard functions
Date: Thu, 20 Jan 2022 15:59:46 -0800
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <ssct1k$651$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jan 2022 23:59:48 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a8e2b217b13d7a1d6f895128bc47c2a6";
logging-data="6305"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Nn1rxAKxAKXg37EWvfC0F"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:z+SD0MAxKQtPRSuIxLQNX6Q4tpI=
Content-Language: en-US
 by: Andrey Tarasevich - Thu, 20 Jan 2022 23:59 UTC

7.1.4 Use of library functions
http://port70.net/~nsz/c/c11/n1570.html#7.1.4p1

7.1.4/1 states that any function declared in a standard header can be
additionally implemented as a function-like macro (unless explicitly
stated otherwise)

"[...] Any function declared in a header may be additionally implemented
as a function-like macro defined in the header [...]"

It also gives some guarantees about the arguments being evaluated
exactly once

"[...] Any invocation of a library function that is implemented as a
macro shall expand to code that evaluates each of its arguments exactly
once, fully protected by parentheses where necessary, so it is generally
safe to use arbitrary expressions as arguments. [...]"

However, that last statement is accompanied by a footnote

"186) Such macros might not contain the sequence points that the
corresponding function calls do"

It appears that this footnote is intended to draw attention to the fact
that normative text does not require macro implementations to fully
match the sequencing properties of a "normal" implementation of the same
standard function.

Is that really the case?

Consider the following example

double x = 1.5;
x = modf(x, &x);

This is fine in case `modf` is actually a function. But does the
standard intend to guarantee that this is specified and defined even if
`modf` is implemented as a macro? I would expect so, and it is quite
possible that the following passage

"[...] Likewise, those function-like macros described in the following
subclauses may be invoked in an expression anywhere a function with a
compatible return type could be called. [...]"

is intended to guarantee exactly that.

But still, what exactly are they trying to point out in footnote 186?

--
Best regards,
Andrey Tarasevich

Re: Sequencing guarantees for macro versions of standard functions

<86k0euq62t.fsf@linuxsc.com>

  copy mid

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

  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: Sequencing guarantees for macro versions of standard functions
Date: Thu, 20 Jan 2022 16:35:06 -0800
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <86k0euq62t.fsf@linuxsc.com>
References: <ssct1k$651$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="9bbd2bd2338bc444f9d0c408d9cb7c1c";
logging-data="11819"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19K6zUktF8AAfhsahWkfKN7GOxUuWsWLp4="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:ZT8wpPWG87pbsrVIxNxNses0neM=
sha1:F4DlInoRYIkWYugx43xa/wdT2/U=
 by: Tim Rentsch - Fri, 21 Jan 2022 00:35 UTC

Andrey Tarasevich <andreytarasevich@hotmail.com> writes:

> 7.1.4 Use of library functions
> http://port70.net/~nsz/c/c11/n1570.html#7.1.4p1
>
> 7.1.4/1 states that any function declared in a standard header can be
> additionally implemented as a function-like macro (unless explicitly
> stated otherwise)
>
> "[...] Any function declared in a header may be additionally
> implemented as a function-like macro defined in the header [...]"
>
> It also gives some guarantees about the arguments being evaluated
> exactly once
>
> "[...] Any invocation of a library function that is implemented as a
> macro shall expand to code that evaluates each of its arguments
> exactly once, fully protected by parentheses where necessary, so it is
> generally safe to use arbitrary expressions as arguments. [...]"
>
> However, that last statement is accompanied by a footnote
>
> "186) Such macros might not contain the sequence points that the
> corresponding function calls do"
>
> It appears that this footnote is intended to draw attention to the
> fact that normative text does not require macro implementations to
> fully match the sequencing properties of a "normal" implementation of
> the same standard function.
>
> Is that really the case?

Yes.

> Consider the following example
>
> double x = 1.5;
> x = modf(x, &x);
>
> This is fine in case `modf` is actually a function. But does the
> standard intend to guarantee that this is specified and defined even
> if `modf` is implemented as a macro?

No.

> I would expect so, and it is quite possible that the following passage
>
> "[...] Likewise, those function-like macros described in the following
> subclauses may be invoked in an expression anywhere a function with a
> compatible return type could be called. [...]"
>
> is intended to guarantee exactly that.

The quoted passage guarantees what it says: such function-like
macros may be /invoked/ anywhere their corresponding functions
could. It does /not/ guarantee that such invocations will work
if there are sequencing issues.

> But still, what exactly are they trying to point out in footnote 186?

If not having the same sequencing guarantees might cause a
problem (ie, if a "call" might invoke a macro rather than calling
a function), avoid using a function call expression that might
invoke a macro, as for example in this particular case

x = (modf)( x, &x );

so that we're sure an actual function call takes place. Hence we
know there will be no sequencing problems. Make sense?

Re: Sequencing guarantees for macro versions of standard functions

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

  copy mid

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

  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: Sequencing guarantees for macro versions of standard functions
Date: Sun, 23 Jan 2022 14:38:22 -0800
Organization: None to speak of
Lines: 51
Message-ID: <87lez6xeld.fsf@nosuchdomain.example.com>
References: <ssct1k$651$1@dont-email.me> <86k0euq62t.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="bf212cab00378f73488330ba3dd56683";
logging-data="3010"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xP3qlF6eSJeFE+kC0WkkR"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:+7s3Aj6awt1/wCUKjufCqDTDeGU=
sha1:ViVRTPYHz/NWyJS25H/v8ZR5v48=
 by: Keith Thompson - Sun, 23 Jan 2022 22:38 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Andrey Tarasevich <andreytarasevich@hotmail.com> writes:
[...]
>> Consider the following example
>>
>> double x = 1.5;
>> x = modf(x, &x);
>>
>> This is fine in case `modf` is actually a function. But does the
>> standard intend to guarantee that this is specified and defined even
>> if `modf` is implemented as a macro?
>
> No.
>
>> I would expect so, and it is quite possible that the following passage
>>
>> "[...] Likewise, those function-like macros described in the following
>> subclauses may be invoked in an expression anywhere a function with a
>> compatible return type could be called. [...]"
>>
>> is intended to guarantee exactly that.
>
> The quoted passage guarantees what it says: such function-like
> macros may be /invoked/ anywhere their corresponding functions
> could. It does /not/ guarantee that such invocations will work
> if there are sequencing issues.
>
>> But still, what exactly are they trying to point out in footnote 186?
>
> If not having the same sequencing guarantees might cause a
> problem (ie, if a "call" might invoke a macro rather than calling
> a function), avoid using a function call expression that might
> invoke a macro, as for example in this particular case
>
> x = (modf)( x, &x );
>
> so that we're sure an actual function call takes place. Hence we
> know there will be no sequencing problems. Make sense?

Or

x = modf(x, &y);
x = y;

(I'm already a bit uncomfortable with x = (modf)(x, &x), though I know
it's well defined.)

--
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: Sequencing guarantees for macro versions of standard functions

<868rv5oldy.fsf@linuxsc.com>

  copy mid

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

  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: Sequencing guarantees for macro versions of standard functions
Date: Sun, 23 Jan 2022 19:36:25 -0800
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <868rv5oldy.fsf@linuxsc.com>
References: <ssct1k$651$1@dont-email.me> <86k0euq62t.fsf@linuxsc.com> <87lez6xeld.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="d742d26243a9575adb46fc0e29496190";
logging-data="742"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/tigCEgDGjA20vEq8Oedes79qqA9a82JM="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:zkbRu97cipi6t2CqmBr+c9WUp0Y=
sha1:cA5LXgdHZpRd6COGnwqvCAoZEQo=
 by: Tim Rentsch - Mon, 24 Jan 2022 03:36 UTC

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

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> Andrey Tarasevich <andreytarasevich@hotmail.com> writes:
>
> [...]
>
>>> Consider the following example
>>>
>>> double x = 1.5;
>>> x = modf(x, &x);
>>>
>>> This is fine in case `modf` is actually a function. But does the
>>> standard intend to guarantee that this is specified and defined even
>>> if `modf` is implemented as a macro?
>>
>> No.
>>
>>> I would expect so, and it is quite possible that the following passage
>>>
>>> "[...] Likewise, those function-like macros described in the following
>>> subclauses may be invoked in an expression anywhere a function with a
>>> compatible return type could be called. [...]"
>>>
>>> is intended to guarantee exactly that.
>>
>> The quoted passage guarantees what it says: such function-like
>> macros may be /invoked/ anywhere their corresponding functions
>> could. It does /not/ guarantee that such invocations will work
>> if there are sequencing issues.
>>
>>> But still, what exactly are they trying to point out in footnote 186?
>>
>> If not having the same sequencing guarantees might cause a
>> problem (ie, if a "call" might invoke a macro rather than calling
>> a function), avoid using a function call expression that might
>> invoke a macro, as for example in this particular case
>>
>> x = (modf)( x, &x );
>>
>> so that we're sure an actual function call takes place. Hence we
>> know there will be no sequencing problems. Make sense?
>
> Or
>
> x = modf(x, &y);
> x = y;
>
> (I'm already a bit uncomfortable with x = (modf)(x, &x), though
> I know it's well defined.)

I understand having a queasy reaction to 'x = (modf)(x, &x)', and
to some degree I have such a reaction myself. I deliberately
chose not to comment about that, since what was being asked about
is only about sequencing issues in macros vs functions.

However, the suggested rewrite has different semantics than the
previous single assignment with function call. If we want to
keep the same semantics but still be able to use the macro
form (but without any sequencing issues), a different writing
is needed, as for example

x = modf( x, (double[]){ 0 } );

Writing the call this way should make it obvious that the value
stored in/through the second argument is ignored and discarded.

Re: Sequencing guarantees for macro versions of standard functions

<ssl80r$h8r$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c
Subject: Re: Sequencing guarantees for macro versions of standard functions
Date: Sun, 23 Jan 2022 19:56:10 -0800
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <ssl80r$h8r$1@dont-email.me>
References: <ssct1k$651$1@dont-email.me> <86k0euq62t.fsf@linuxsc.com>
<87lez6xeld.fsf@nosuchdomain.example.com> <868rv5oldy.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 24 Jan 2022 03:56:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a41c7ef206e29f2fa896025e517cdefd";
logging-data="17691"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18OlvVzkGcznZYhAI5s26Yc"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:dNbJ5N5tMTHFY6bV5KJiLqbnKUs=
In-Reply-To: <868rv5oldy.fsf@linuxsc.com>
Content-Language: en-US
 by: Andrey Tarasevich - Mon, 24 Jan 2022 03:56 UTC

On 1/23/2022 7:36 PM, Tim Rentsch wrote:
>
> However, the suggested rewrite has different semantics than the
> previous single assignment with function call. If we want to
> keep the same semantics but still be able to use the macro
> form (but without any sequencing issues), a different writing
> is needed, as for example
>
> x = modf( x, (double[]){ 0 } );
>
> Writing the call this way should make it obvious that the value
> stored in/through the second argument is ignored and discarded.

That would be

x = modf( x, &(double[]){ 0 } );

--
Best regards,
Andrey Tarasevich

Re: Sequencing guarantees for macro versions of standard functions

<ssl84t$h8r$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c
Subject: Re: Sequencing guarantees for macro versions of standard functions
Date: Sun, 23 Jan 2022 19:58:20 -0800
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <ssl84t$h8r$2@dont-email.me>
References: <ssct1k$651$1@dont-email.me> <86k0euq62t.fsf@linuxsc.com>
<87lez6xeld.fsf@nosuchdomain.example.com> <868rv5oldy.fsf@linuxsc.com>
<ssl80r$h8r$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 24 Jan 2022 03:58:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a41c7ef206e29f2fa896025e517cdefd";
logging-data="17691"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/UUQ2mh22eicFE1VSfbjbA"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:3oEuJ8i67zTfRezl7urWQFhry28=
In-Reply-To: <ssl80r$h8r$1@dont-email.me>
Content-Language: en-US
 by: Andrey Tarasevich - Mon, 24 Jan 2022 03:58 UTC

On 1/23/2022 7:56 PM, Andrey Tarasevich wrote:
> On 1/23/2022 7:36 PM, Tim Rentsch wrote:
>>
>> However, the suggested rewrite has different semantics than the
>> previous single assignment with function call.  If we want to
>> keep the same semantics but still be able to use the macro
>> form (but without any sequencing issues), a different writing
>> is needed, as for example
>>
>>      x = modf( x, (double[]){ 0 } );
>>
>> Writing the call this way should make it obvious that the value
>> stored in/through the second argument is ignored and discarded.
>
> That would be
>
>       x = modf( x, &(double[]){ 0 } );
>

Opps, my sitake. Sorry, I missed the `[]` part.

Of course, your original variant is correct. Although I don't see the
point of bringing arrays into the picture. One can just do

x = modf( x, &(double){ 0 } );

--
Best regards,
Andrey Tarasevich

Re: Sequencing guarantees for macro versions of standard functions

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

  copy mid

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

  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: Sequencing guarantees for macro versions of standard functions
Date: Sun, 23 Jan 2022 23:49:29 -0800
Organization: None to speak of
Lines: 73
Message-ID: <87r18xo9o6.fsf@nosuchdomain.example.com>
References: <ssct1k$651$1@dont-email.me> <86k0euq62t.fsf@linuxsc.com>
<87lez6xeld.fsf@nosuchdomain.example.com> <868rv5oldy.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="94b3a3008f708f7b40cdf3a125e51cf3";
logging-data="11858"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18caZvjB+xVyXtSY7lHlJoD"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:sUoNCL0mY5QC9oipSelqbX8JUtc=
sha1:ivpiy7oId3WQJ6yoKtlqDpHy7wo=
 by: Keith Thompson - Mon, 24 Jan 2022 07:49 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>> Andrey Tarasevich <andreytarasevich@hotmail.com> writes:
>> [...]
>>
>>>> Consider the following example
>>>>
>>>> double x = 1.5;
>>>> x = modf(x, &x);
>>>>
>>>> This is fine in case `modf` is actually a function. But does the
>>>> standard intend to guarantee that this is specified and defined even
>>>> if `modf` is implemented as a macro?
>>>
>>> No.
>>>
>>>> I would expect so, and it is quite possible that the following passage
>>>>
>>>> "[...] Likewise, those function-like macros described in the following
>>>> subclauses may be invoked in an expression anywhere a function with a
>>>> compatible return type could be called. [...]"
>>>>
>>>> is intended to guarantee exactly that.
>>>
>>> The quoted passage guarantees what it says: such function-like
>>> macros may be /invoked/ anywhere their corresponding functions
>>> could. It does /not/ guarantee that such invocations will work
>>> if there are sequencing issues.
>>>
>>>> But still, what exactly are they trying to point out in footnote 186?
>>>
>>> If not having the same sequencing guarantees might cause a
>>> problem (ie, if a "call" might invoke a macro rather than calling
>>> a function), avoid using a function call expression that might
>>> invoke a macro, as for example in this particular case
>>>
>>> x = (modf)( x, &x );
>>>
>>> so that we're sure an actual function call takes place. Hence we
>>> know there will be no sequencing problems. Make sense?
>>
>> Or
>>
>> x = modf(x, &y);
>> x = y;
>>
>> (I'm already a bit uncomfortable with x = (modf)(x, &x), though
>> I know it's well defined.)
>
> I understand having a queasy reaction to 'x = (modf)(x, &x)', and
> to some degree I have such a reaction myself. I deliberately
> chose not to comment about that, since what was being asked about
> is only about sequencing issues in macros vs functions.
>
> However, the suggested rewrite has different semantics than the
> previous single assignment with function call. If we want to
> keep the same semantics but still be able to use the macro
> form (but without any sequencing issues), a different writing
> is needed, as for example
>
> x = modf( x, (double[]){ 0 } );
>
> Writing the call this way should make it obvious that the value
> stored in/through the second argument is ignored and discarded.

Right, I should have paid closer attention to the semantics of modf()
(which I don't think I've ever used "in anger").

--
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: Sequencing guarantees for macro versions of standard functions

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

  copy mid

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

  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: Sequencing guarantees for macro versions of standard functions
Date: Sun, 23 Jan 2022 23:50:33 -0800
Organization: None to speak of
Lines: 34
Message-ID: <87mtjlo9me.fsf@nosuchdomain.example.com>
References: <ssct1k$651$1@dont-email.me> <86k0euq62t.fsf@linuxsc.com>
<87lez6xeld.fsf@nosuchdomain.example.com> <868rv5oldy.fsf@linuxsc.com>
<ssl80r$h8r$1@dont-email.me> <ssl84t$h8r$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="94b3a3008f708f7b40cdf3a125e51cf3";
logging-data="11858"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX186kmzQFum/mYRFtxRIdGU3"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:I2WAIBsmeBEtR8fchKi3nK99ky8=
sha1:OqLrbskuvYCLcxiYRlbX1azCwLI=
 by: Keith Thompson - Mon, 24 Jan 2022 07:50 UTC

Andrey Tarasevich <andreytarasevich@hotmail.com> writes:
> On 1/23/2022 7:56 PM, Andrey Tarasevich wrote:
>> On 1/23/2022 7:36 PM, Tim Rentsch wrote:
>>>
>>> However, the suggested rewrite has different semantics than the
>>> previous single assignment with function call.  If we want to
>>> keep the same semantics but still be able to use the macro
>>> form (but without any sequencing issues), a different writing
>>> is needed, as for example
>>>
>>>      x = modf( x, (double[]){ 0 } );
>>>
>>> Writing the call this way should make it obvious that the value
>>> stored in/through the second argument is ignored and discarded.
>> That would be
>>       x = modf( x, &(double[]){ 0 } );
>>
>
> Opps, my sitake. Sorry, I missed the `[]` part.
>
> Of course, your original variant is correct. Although I don't see the
> point of bringing arrays into the picture. One can just do
>
> x = modf( x, &(double){ 0 } );

My preference would be:

double ignored;
x = modf(x, &ignored);

--
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: Sequencing guarantees for macro versions of standard functions

<864k5tnohj.fsf@linuxsc.com>

  copy mid

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

  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: Sequencing guarantees for macro versions of standard functions
Date: Mon, 24 Jan 2022 07:27:04 -0800
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <864k5tnohj.fsf@linuxsc.com>
References: <ssct1k$651$1@dont-email.me> <86k0euq62t.fsf@linuxsc.com> <87lez6xeld.fsf@nosuchdomain.example.com> <868rv5oldy.fsf@linuxsc.com> <ssl80r$h8r$1@dont-email.me> <ssl84t$h8r$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="d742d26243a9575adb46fc0e29496190";
logging-data="3706"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XzL7hm22/JoTrC/NZGSepX2uWPrwCVTw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:bHr6ofIO3uQSep45JGCSFFUnMh4=
sha1:ePoNpg1FG4b5JBFRI+pXdL/utlo=
 by: Tim Rentsch - Mon, 24 Jan 2022 15:27 UTC

Andrey Tarasevich <andreytarasevich@hotmail.com> writes:

> On 1/23/2022 7:56 PM, Andrey Tarasevich wrote:
>
>> On 1/23/2022 7:36 PM, Tim Rentsch wrote:
>>
>>> However, the suggested rewrite has different semantics than the
>>> previous single assignment with function call. If we want to
>>> keep the same semantics but still be able to use the macro
>>> form (but without any sequencing issues), a different writing
>>> is needed, as for example
>>>
>>> x = modf( x, (double[]){ 0 } );
>>>
>>> Writing the call this way should make it obvious that the value
>>> stored in/through the second argument is ignored and discarded.
>>
>> That would be
>>
>> x = modf( x, &(double[]){ 0 } );
>
> Opps, my sitake. Sorry, I missed the `[]` part.
>
> Of course, your original variant is correct. Although I don't see
> the point of bringing arrays into the picture. One can just do
>
> x = modf( x, &(double){ 0 } );

For no particular reason I can point to (no pun intended), in
situations like this one I normally use the array type form in
preference to the & form. I find it easier to digest, and also
think it expresses more directly what I want to convey. I'm sure
many people would normally use the & form, and I'm okay with that
choice, but it doesn't change my choice.

Re: Sequencing guarantees for macro versions of standard functions

<86zgnlm9px.fsf@linuxsc.com>

  copy mid

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

  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: Sequencing guarantees for macro versions of standard functions
Date: Mon, 24 Jan 2022 07:31:22 -0800
Organization: A noiseless patient Spider
Lines: 77
Message-ID: <86zgnlm9px.fsf@linuxsc.com>
References: <ssct1k$651$1@dont-email.me> <86k0euq62t.fsf@linuxsc.com> <87lez6xeld.fsf@nosuchdomain.example.com> <868rv5oldy.fsf@linuxsc.com> <87r18xo9o6.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="d742d26243a9575adb46fc0e29496190";
logging-data="3706"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18w9S4umaUx8eEkk/o9mZUMkwQlaYC+z/4="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:MwlhyYUjRSe8rfsgmHUp3t5XpoE=
sha1:lVTzV8BuQP4O043UJ+Ww+w4Kn5I=
 by: Tim Rentsch - Mon, 24 Jan 2022 15:31 UTC

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

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>
>>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>>
>>>> Andrey Tarasevich <andreytarasevich@hotmail.com> writes:
>>>
>>> [...]
>>>
>>>>> Consider the following example
>>>>>
>>>>> double x = 1.5;
>>>>> x = modf(x, &x);
>>>>>
>>>>> This is fine in case `modf` is actually a function. But does the
>>>>> standard intend to guarantee that this is specified and defined even
>>>>> if `modf` is implemented as a macro?
>>>>
>>>> No.
>>>>
>>>>> I would expect so, and it is quite possible that the following passage
>>>>>
>>>>> "[...] Likewise, those function-like macros described in the following
>>>>> subclauses may be invoked in an expression anywhere a function with a
>>>>> compatible return type could be called. [...]"
>>>>>
>>>>> is intended to guarantee exactly that.
>>>>
>>>> The quoted passage guarantees what it says: such function-like
>>>> macros may be /invoked/ anywhere their corresponding functions
>>>> could. It does /not/ guarantee that such invocations will work
>>>> if there are sequencing issues.
>>>>
>>>>> But still, what exactly are they trying to point out in footnote 186?
>>>>
>>>> If not having the same sequencing guarantees might cause a
>>>> problem (ie, if a "call" might invoke a macro rather than calling
>>>> a function), avoid using a function call expression that might
>>>> invoke a macro, as for example in this particular case
>>>>
>>>> x = (modf)( x, &x );
>>>>
>>>> so that we're sure an actual function call takes place. Hence we
>>>> know there will be no sequencing problems. Make sense?
>>>
>>> Or
>>>
>>> x = modf(x, &y);
>>> x = y;
>>>
>>> (I'm already a bit uncomfortable with x = (modf)(x, &x), though
>>> I know it's well defined.)
>>
>> I understand having a queasy reaction to 'x = (modf)(x, &x)', and
>> to some degree I have such a reaction myself. I deliberately
>> chose not to comment about that, since what was being asked about
>> is only about sequencing issues in macros vs functions.
>>
>> However, the suggested rewrite has different semantics than the
>> previous single assignment with function call. If we want to
>> keep the same semantics but still be able to use the macro
>> form (but without any sequencing issues), a different writing
>> is needed, as for example
>>
>> x = modf( x, (double[]){ 0 } );
>>
>> Writing the call this way should make it obvious that the value
>> stored in/through the second argument is ignored and discarded.
>
> Right, I should have paid closer attention to the semantics of modf()
> (which I don't think I've ever used "in anger").

Why do you make the "in anger" comment? I couldn't find any
connection to earlier remarks in this thread.

Re: Sequencing guarantees for macro versions of standard functions

<874k5somst.fsf@nosuchdomain.example.com>

  copy mid

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

  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: Sequencing guarantees for macro versions of standard functions
Date: Mon, 24 Jan 2022 13:18:10 -0800
Organization: None to speak of
Lines: 22
Message-ID: <874k5somst.fsf@nosuchdomain.example.com>
References: <ssct1k$651$1@dont-email.me> <86k0euq62t.fsf@linuxsc.com>
<87lez6xeld.fsf@nosuchdomain.example.com> <868rv5oldy.fsf@linuxsc.com>
<87r18xo9o6.fsf@nosuchdomain.example.com> <86zgnlm9px.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="94b3a3008f708f7b40cdf3a125e51cf3";
logging-data="19835"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18N43MgfHwk1d4FHnAGfp2N"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:JjVsTWZk4fMLHDVyqceF6A5SS2A=
sha1:8umBa756dSVyZ4w1YYS1IkNc6fE=
 by: Keith Thompson - Mon, 24 Jan 2022 21:18 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
[...]
>> Right, I should have paid closer attention to the semantics of modf()
>> (which I don't think I've ever used "in anger").
>
> Why do you make the "in anger" comment? I couldn't find any
> connection to earlier remarks in this thread.

It's a figure of speech. Quoting a comment I found on Hacker News:

To "use something in anger" is a phrase, meaning to use something
"for real" - in production, etc. rather than just to try it out.

No actual anger is implied.

https://news.ycombinator.com/item?id=10806244

--
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: Sequencing guarantees for macro versions of standard functions

<86ilu2n57y.fsf@linuxsc.com>

  copy mid

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

  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: Sequencing guarantees for macro versions of standard functions
Date: Sat, 29 Jan 2022 03:36:49 -0800
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <86ilu2n57y.fsf@linuxsc.com>
References: <ssct1k$651$1@dont-email.me> <86k0euq62t.fsf@linuxsc.com> <87lez6xeld.fsf@nosuchdomain.example.com> <868rv5oldy.fsf@linuxsc.com> <87r18xo9o6.fsf@nosuchdomain.example.com> <86zgnlm9px.fsf@linuxsc.com> <874k5somst.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="8a9fc8cdb13989d258a574a29792b8b1";
logging-data="4218"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19glDT5iIW32H8SWEXeMtdITgU/L7GDLs0="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:NR1noyX+ZQTLRTt0KH41DMUPnO4=
sha1:omjJ8aF9bhOWU6vZEHClJ45DXp8=
 by: Tim Rentsch - Sat, 29 Jan 2022 11:36 UTC

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

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>
> [...]
>
>>> Right, I should have paid closer attention to the semantics of modf()
>>> (which I don't think I've ever used "in anger").
>>
>> Why do you make the "in anger" comment? I couldn't find any
>> connection to earlier remarks in this thread.
>
> It's a figure of speech. Quoting a comment I found on Hacker News:
>
> To "use something in anger" is a phrase, meaning to use something
> "for real" - in production, etc. rather than just to try it out.
>
> No actual anger is implied.

I see. I wasn't aware of that idiom.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor