Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Real Programmers don't eat quiche. They eat Twinkies and Szechwan food.


devel / comp.lang.c / Re: Does this program have the specified behavior?

SubjectAuthor
* Do this program have the specified behavior?olcott
`* Does this program have the specified behavior?olcott
 +* Re: Does this program have the specified behavior?Chris M. Thomasson
 |`* Re: Does this program have the specified behavior?Mark Bluemel
 | +- Re: Does this program have the specified behavior?olcott
 | `* Re: Does this program have the specified behavior?Tim Rentsch
 |  +* Re: Does this program have the specified behavior?Richard Damon
 |  |`* Re: Does this program have the specified behavior?Tim Rentsch
 |  | `* Re: Does this program have the specified behavior?Keith Thompson
 |  |  `- Re: Does this program have the specified behavior?Tim Rentsch
 |  `* Re: Does this program have the specified behavior?antispam
 |   +- Re: Does this program have the specified behavior?Keith Thompson
 |   `- Re: Does this program have the specified behavior?Tim Rentsch
 +* Re: Does this program have the specified behavior?Richard Damon
 |`* Re: Does this program have the specified behavior?olcott
 | `* Re: Does this program have the specified behavior?Juha Nieminen
 |  +* Re: Does this program have the specified behavior?Ben Bacarisse
 |  |`- Re: Does this program have the specified behavior?olcott
 |  `- Re: Does this program have the specified behavior?olcott
 `- Re: Does this program have the specified behavior?Anurag Ranjan

1
Do this program have the specified behavior?

<TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 16 Nov 2021 21:33:29 -0600
Date: Tue, 16 Nov 2021 21:33:28 -0600
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
Newsgroups: comp.lang.c++,comp.lang.c
Content-Language: en-US
From: NoO...@NoWhere.com (olcott)
Subject: Do this program have the specified behavior?
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
Lines: 30
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-QvK4ETW1irpClAU386tj1vmH0faaYxCVzLpQjRRoiA9x+aLgIC40A5AorcPhoEI68BhOonfvvpaxM/x!BuvZjik/FHv8kYEdjWmDUrSyc66PbGOPbxIi2qJormVnXlj3r5QEgx6z/8TuWtxnJTgYE+TMo7ww!Zg==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 1590
 by: olcott - Wed, 17 Nov 2021 03:33 UTC

#include <stdint.h>
typedef void (*ptr)();

int H(ptr x, ptr y)
{ x(y); // direct execution of P(P)
return 1;
}

int P(ptr x)
{ H(x, x);
return 1;
}

int main(void)
{ H(P, P);
}

For every H that simulates or executes its input and aborts or does not
abort its input P never reaches its last instruction.

--
Copyright 2021 Pete Olcott

Talent hits a target no one else can hit;
Genius hits a target no one else can see.
Arthur Schopenhauer

Does this program have the specified behavior?

<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 16 Nov 2021 22:46:32 -0600
Date: Tue, 16 Nov 2021 22:46:31 -0600
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
Subject: Does this program have the specified behavior?
Content-Language: en-US
Newsgroups: comp.lang.c++,comp.lang.c
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
From: NoO...@NoWhere.com (olcott)
In-Reply-To: <2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
Lines: 39
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-RfLNSjeDgNNCGThee1/aptl908CvEghyD09YpgxyfOVn5DIMuM8wUaZfls4AJrNydqim2JbH0rbbtNg!hs76TZN7++IGKUqZDZvJ6zMPVZd96txhgoLzKvNe8Tj6+dIlmnvQIk0SX0r0YlygoD3cbYD/LkIn!FA==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 2092
 by: olcott - Wed, 17 Nov 2021 04:46 UTC

On 11/16/2021 10:10 PM, wij wrote:
> On Wednesday, 17 November 2021 at 11:33:49 UTC+8, olcott wrote:

#include <stdint.h>
#include <stdio.h>
typedef int (*ptr)();

int H(ptr x, ptr y)
{ x(y); // direct execution of P(P)
return 1;
}

int P(ptr x)
{ H(x, x);
return 1;
}

int main(void)
{ H(P, P);
}

For every H that simulates or executes its input and aborts or does not
abort its input P never reaches its last instruction.

> I would guess yes, it is specified: BAD, illegal program

It must be compiled as C and the typedef was incorrect.
I can't find a way to specify the "C" calling convention for g++

--
Copyright 2021 Pete Olcott

Talent hits a target no one else can hit;
Genius hits a target no one else can see.
Arthur Schopenhauer

Re: Does this program have the specified behavior?

<sn230n$q4t$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: Does this program have the specified behavior?
Date: Tue, 16 Nov 2021 21:12:53 -0800
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <sn230n$q4t$1@dont-email.me>
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 17 Nov 2021 05:12:56 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2f6405ce1d8a388faf4b8f74566db8ab";
logging-data="26781"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nqHGObVOoluw2vYpoRq75xAM+yAmz0dk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
Cancel-Lock: sha1:+LNWSKpLbAkiZ7ODUMM4El06A+Q=
In-Reply-To: <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 17 Nov 2021 05:12 UTC

On 11/16/2021 8:46 PM, olcott wrote:
> #include <stdint.h>
> #include <stdio.h>
> typedef int (*ptr)();
>
> int H(ptr x, ptr y)
> {
>   x(y); // direct execution of P(P)
>   return 1;
> }
>
> int P(ptr x)
> {
>   H(x, x);
>   return 1;
> }
>
> int main(void)
> {
>   H(P, P);
> }

Stack overflow...

Re: Does this program have the specified behavior?

<3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:a6d0:: with SMTP id p199mr11427409qke.505.1637137729342;
Wed, 17 Nov 2021 00:28:49 -0800 (PST)
X-Received: by 2002:a05:622a:3d3:: with SMTP id k19mr14988289qtx.334.1637137729161;
Wed, 17 Nov 2021 00:28:49 -0800 (PST)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 17 Nov 2021 00:28:48 -0800 (PST)
In-Reply-To: <sn230n$q4t$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23c7:a280:3401:c1c9:3a89:3b41:e6d9;
posting-account=3LA7mQoAAAByiBtHIUvpFq0_QEKnHGc9
NNTP-Posting-Host: 2a00:23c7:a280:3401:c1c9:3a89:3b41:e6d9
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com> <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
<sn230n$q4t$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com>
Subject: Re: Does this program have the specified behavior?
From: mark.blu...@gmail.com (Mark Bluemel)
Injection-Date: Wed, 17 Nov 2021 08:28:49 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2034
 by: Mark Bluemel - Wed, 17 Nov 2021 08:28 UTC

On Wednesday, 17 November 2021 at 05:13:08 UTC, Chris M. Thomasson wrote:
> On 11/16/2021 8:46 PM, olcott wrote:
> > #include <stdint.h>
> > #include <stdio.h>
> > typedef int (*ptr)();
> >
> > int H(ptr x, ptr y)
> > {
> > x(y); // direct execution of P(P)
> > return 1;
> > }
> >
> > int P(ptr x)
> > {
> > H(x, x);
> > return 1;
> > }
> >
> > int main(void)
> > {
> > H(P, P);
> > }
> Stack overflow...

Surely a compiler can optimise this to remove the recursion, and for that matter, remove any functionality at all, as the code has no observable behaviour, as far as I can see (I'd be happy to be corrected on this!).

$DIETY only knows what olcott was trying to show with this code.

Re: Does this program have the specified behavior?

<536lJ.49729$JZ3.33398@fx05.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx05.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.3.1
Subject: Re: Does this program have the specified behavior?
Content-Language: en-US
Newsgroups: comp.lang.c++,comp.lang.c
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 49
Message-ID: <536lJ.49729$JZ3.33398@fx05.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Wed, 17 Nov 2021 06:53:36 -0500
X-Received-Bytes: 2389
 by: Richard Damon - Wed, 17 Nov 2021 11:53 UTC

On 11/16/21 11:46 PM, olcott wrote:
> On 11/16/2021 10:10 PM, wij wrote:
>> On Wednesday, 17 November 2021 at 11:33:49 UTC+8, olcott wrote:
>
> #include <stdint.h>
> #include <stdio.h>
> typedef int (*ptr)();
>
> int H(ptr x, ptr y)
> {
>   x(y); // direct execution of P(P)
>   return 1;
> }
>
> int P(ptr x)
> {
>   H(x, x);
>   return 1;
> }
>
> int main(void)
> {
>   H(P, P);
> }
>
> For every H that simulates or executes its input and aborts or does not
> abort its input P never reaches its last instruction.
>
>> I would guess yes, it is specified: BAD, illegal program
>
> It must be compiled as C and the typedef was incorrect.
> I can't find a way to specify the "C" calling convention for g++
>

Shows you don't understand C++.

Making it 'C' calling convention doesn't change the syntax for the call.

In C++, an empty parameter list specifies a void parameter list, while
in C it specifies tha mostly obsolete concept that this is a
non-prototype declaration that doesn't specify the parameters.

Ultimately the problem is that this runs into the issue that it is
impossible to express in C a function that takes or returns a pointer to
the same type as the function itself is, as that requires self
references in the type definition.

Re: Does this program have the specified behavior?

<Fb6dnZbpVugnjwj8nZ2dnUU7-RudnZ2d@giganews.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 17 Nov 2021 08:33:30 -0600
Date: Wed, 17 Nov 2021 08:33:29 -0600
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
Subject: Re: Does this program have the specified behavior?
Content-Language: en-US
Newsgroups: comp.lang.c,comp.lang.c++
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com> <sn230n$q4t$1@dont-email.me>
<3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com>
From: NoO...@NoWhere.com (olcott)
In-Reply-To: <3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <Fb6dnZbpVugnjwj8nZ2dnUU7-RudnZ2d@giganews.com>
Lines: 45
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-NVGJtLLLB5r64P/4dOSBsqdgSIhPXYl5mX9d24sjBI0EcYLW+CW4UFDO05xduZEiQnfHUY7ll6IMBLa!lnm60xPB73j3Iyoftedj1Qz0si6BAE5QbWqRf/7EQ16HklxLJhIq0TRJQwTm1FlmLnvC6k2B/DYQ!NA==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 2540
 by: olcott - Wed, 17 Nov 2021 14:33 UTC

On 11/17/2021 2:28 AM, Mark Bluemel wrote:
> On Wednesday, 17 November 2021 at 05:13:08 UTC, Chris M. Thomasson wrote:
>> On 11/16/2021 8:46 PM, olcott wrote:
>>> #include <stdint.h>
>>> #include <stdio.h>
>>> typedef int (*ptr)();
>>>
>>> int H(ptr x, ptr y)
>>> {
>>> x(y); // direct execution of P(P)
>>> return 1;
>>> }
>>>
>>> int P(ptr x)
>>> {
>>> H(x, x);
>>> return 1;
>>> }
>>>
>>> int main(void)
>>> {
>>> H(P, P);
>>> }
>> Stack overflow...
>
> Surely a compiler can optimise this to remove the recursion, and for that matter, remove any functionality at all, as the code has no observable behaviour, as far as I can see (I'd be happy to be corrected on this!).
>

This is the question:
For every H that simulates or executes its input and aborts or does not
abort its input does any P ever reach its last instruction?

> $DIETY only knows what olcott was trying to show with this code.
>

--
Copyright 2021 Pete Olcott

Talent hits a target no one else can hit;
Genius hits a target no one else can see.
Arthur Schopenhauer

Re: Does this program have the specified behavior?

<dtOdnfVlRJHziwj8nZ2dnUU7-QHNnZ2d@giganews.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 17 Nov 2021 08:49:18 -0600
Date: Wed, 17 Nov 2021 08:49:16 -0600
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
Subject: Re: Does this program have the specified behavior?
Content-Language: en-US
Newsgroups: comp.lang.c++,comp.lang.c
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
<536lJ.49729$JZ3.33398@fx05.iad>
From: NoO...@NoWhere.com (olcott)
In-Reply-To: <536lJ.49729$JZ3.33398@fx05.iad>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Message-ID: <dtOdnfVlRJHziwj8nZ2dnUU7-QHNnZ2d@giganews.com>
Lines: 65
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-6zK2TSpoUWD1ttoYMNExv/6xyIkgbJM4m+wFryVkbhKvDKjP26nNRg9ZAlpKn62g97liOBvZHhVufZd!TnFVJpvizytL2CAnBjwZvNZ2Jbcpb6W7XmCCzUFrOixZdmEvZh69mID416n0AvCftMSXKB0LWZ0x!Zw==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 3163
 by: olcott - Wed, 17 Nov 2021 14:49 UTC

On 11/17/2021 5:53 AM, Richard Damon wrote:
> On 11/16/21 11:46 PM, olcott wrote:
>> On 11/16/2021 10:10 PM, wij wrote:
>>> On Wednesday, 17 November 2021 at 11:33:49 UTC+8, olcott wrote:
>>
>> #include <stdint.h>
>> #include <stdio.h>
>> typedef int (*ptr)();
>>
>> int H(ptr x, ptr y)
>> {
>>    x(y); // direct execution of P(P)
>>    return 1;
>> }
>>
>> int P(ptr x)
>> {
>>    H(x, x);
>>    return 1;
>> }
>>
>> int main(void)
>> {
>>    H(P, P);
>> }
>>
>> For every H that simulates or executes its input and aborts or does not
>> abort its input P never reaches its last instruction.
>>
>>> I would guess yes, it is specified: BAD, illegal program
>>
>> It must be compiled as C and the typedef was incorrect.
>> I can't find a way to specify the "C" calling convention for g++
>>
>
> Shows you don't understand C++.
>
> Making it 'C' calling convention doesn't change the syntax for the call.
>
> In C++, an empty parameter list specifies a void parameter list, while
> in C it specifies tha mostly obsolete concept that this is a
> non-prototype declaration that doesn't specify the parameters.
>
> Ultimately the problem is that this runs into the issue that it is
> impossible to express in C a function that takes or returns a pointer to
> the same type as the function itself is, as that requires self
> references in the type definition.
>

This code does compile and run correctly.
The only difference from Ben's code is that
void (*ptr)(); was changed to int (*ptr)();

In comp.lang.c On 11/11/2021 2:31 PM, Ben Bacarisse:
transformed my syntax into his syntax

--
Copyright 2021 Pete Olcott

Talent hits a target no one else can hit;
Genius hits a target no one else can see.
Arthur Schopenhauer

Re: Does this program have the specified behavior?

<sn3v58$a87$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!wfCiSHnELlsUCCjf2V9EWA.user.46.165.242.91.POSTED!not-for-mail
From: anuragra...@gmail.com (Anurag Ranjan)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: Does this program have the specified behavior?
Date: Wed, 17 Nov 2021 22:00:00 +0000
Organization: Aioe.org NNTP Server
Message-ID: <sn3v58$a87$1@gioia.aioe.org>
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: quoted-printable
Injection-Info: gioia.aioe.org; logging-data="10503"; posting-host="wfCiSHnELlsUCCjf2V9EWA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: Anurag Ranjan - Wed, 17 Nov 2021 22:00 UTC

On 17/11/2021 04:46, Wolcott wrote:
> On 11/16/2021 10:10 PM, wij wrote:
>> On Wednesday, 17 November 2021 at 11:33:49 UTC+8, olcott wrote:
>
>
>

#include <stdio.h>

void count(int n)
{ static int d = 1;
printf("n = %d\n", n);
printf("d = %d\n", d);

d++;

if (n > 1)
{
count(n - 1);
}
printf("d = %d\n", d);
} int main()
{ count(5);
return 0;
}

Re: Does this program have the specified behavior?

<sn4s2o$tke$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!NK0c7qMEn6mmBWqphs27pg.user.46.165.242.75.POSTED!not-for-mail
From: nos...@thanks.invalid (Juha Nieminen)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: Does this program have the specified behavior?
Date: Thu, 18 Nov 2021 06:32:58 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <sn4s2o$tke$1@gioia.aioe.org>
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com> <2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com> <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com> <536lJ.49729$JZ3.33398@fx05.iad> <dtOdnfVlRJHziwj8nZ2dnUU7-QHNnZ2d@giganews.com>
Injection-Info: gioia.aioe.org; logging-data="30350"; posting-host="NK0c7qMEn6mmBWqphs27pg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/5.4.42-grsec-kapsi (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: Juha Nieminen - Thu, 18 Nov 2021 06:32 UTC

In comp.lang.c++ olcott <NoOne@nowhere.com> wrote:
>>> typedef int (*ptr)();
>>>
>>> int H(ptr x, ptr y)
>>> {
>>> x(y); // direct execution of P(P)
>>> return 1;
>>> }
>
> This code does compile and run correctly.

It might compile as C, but it shouldn't compile as C++, because it's trying
to call an int(*)() with a parameter, even though that function (that the
pointer is pointing to does not take any parameter.)

Perhaps if it were an int(*)(void*) and then you reinterpret-cast the
parameter in order to call it, then it would compile.

As for "runs correctly", I don't see how this "runs correctly". Unless you
mean an infinite recursion that does nothing "runs correctly".

Re: Does this program have the specified behavior?

<874k89ogte.fsf@bsb.me.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: Does this program have the specified behavior?
Date: Thu, 18 Nov 2021 11:15:41 +0000
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <874k89ogte.fsf@bsb.me.uk>
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
<536lJ.49729$JZ3.33398@fx05.iad>
<dtOdnfVlRJHziwj8nZ2dnUU7-QHNnZ2d@giganews.com>
<sn4s2o$tke$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="b6e96055cde3ec5785fc7fa92034678e";
logging-data="17440"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19boZCW4OChlEfIpxjwliQm7NgExhT9Ehk="
Cancel-Lock: sha1:cqEr/4n34vJ04aPLHDrVKfYnWlM=
sha1:k5lq2NNVYd6n9KlT47I4AKMtepY=
X-BSB-Auth: 1.a0ed9f7fda913165b909.20211118111541GMT.874k89ogte.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 18 Nov 2021 11:15 UTC

Juha Nieminen <nospam@thanks.invalid> writes:

> In comp.lang.c++ olcott <NoOne@nowhere.com> wrote:
>>>> typedef int (*ptr)();
>>>>
>>>> int H(ptr x, ptr y)
>>>> {
>>>> x(y); // direct execution of P(P)
>>>> return 1;
>>>> }
>>
>> This code does compile and run correctly.
>
> It might compile as C, but it shouldn't compile as C++, because it's trying
> to call an int(*)() with a parameter, even though that function (that the
> pointer is pointing to does not take any parameter.)

Just as it must not compile in C++, this code must compile in C. The
meaning of empty ()s in a function declaration is different between the
two languages.

When I tidied up the code, I wrote C, not C++, because C has a more
suitable type available.

--
Ben.

Re: Does this program have the specified behavior?

<6oudnUkQRd6U9wv8nZ2dnUU7-e2dnZ2d@giganews.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 18 Nov 2021 08:58:17 -0600
Date: Thu, 18 Nov 2021 08:58:17 -0600
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
Subject: Re: Does this program have the specified behavior?
Content-Language: en-US
Newsgroups: comp.lang.c++,comp.lang.c
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
<536lJ.49729$JZ3.33398@fx05.iad>
<dtOdnfVlRJHziwj8nZ2dnUU7-QHNnZ2d@giganews.com> <sn4s2o$tke$1@gioia.aioe.org>
From: NoO...@NoWhere.com (olcott)
In-Reply-To: <sn4s2o$tke$1@gioia.aioe.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <6oudnUkQRd6U9wv8nZ2dnUU7-e2dnZ2d@giganews.com>
Lines: 35
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-xUwxcUHPH5YOIsUig8AuXxpS9LuWYCqjyrQQHrvj6V3RfzPHQj93UBSyYjBAkExyzhT9BKFax5zifMQ!K6FtSpATtcA7ayid7wpBhnlvEthK5Y5BwS+WggaT44dPpuJZ04d86aYRETYnrKC8FWH9wUo/KhN/!zQ==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 2593
 by: olcott - Thu, 18 Nov 2021 14:58 UTC

On 11/18/2021 12:32 AM, Juha Nieminen wrote:
> In comp.lang.c++ olcott <NoOne@nowhere.com> wrote:
>>>> typedef int (*ptr)();
>>>>
>>>> int H(ptr x, ptr y)
>>>> {
>>>> x(y); // direct execution of P(P)
>>>> return 1;
>>>> }
>>
>> This code does compile and run correctly.
>
> It might compile as C, but it shouldn't compile as C++, because it's trying
> to call an int(*)() with a parameter, even though that function (that the
> pointer is pointing to does not take any parameter.)
>
> Perhaps if it were an int(*)(void*) and then you reinterpret-cast the
> parameter in order to call it, then it would compile.
>
> As for "runs correctly", I don't see how this "runs correctly". Unless you
> mean an infinite recursion that does nothing "runs correctly".
>

This is the question that I am asking:

Does this program have the specified behavior?
For every H that simulates or executes its input and aborts or does not
abort its input P never reaches its last instruction.

--
Copyright 2021 Pete Olcott

Talent hits a target no one else can hit;
Genius hits a target no one else can see.
Arthur Schopenhauer

Re: Does this program have the specified behavior?

<6oudnUgQRd6o9wv8nZ2dnUU7-e2dnZ2d@giganews.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 18 Nov 2021 08:59:01 -0600
Date: Thu, 18 Nov 2021 08:59:00 -0600
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
Subject: Re: Does this program have the specified behavior?
Content-Language: en-US
Newsgroups: comp.lang.c++,comp.lang.c
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
<536lJ.49729$JZ3.33398@fx05.iad>
<dtOdnfVlRJHziwj8nZ2dnUU7-QHNnZ2d@giganews.com> <sn4s2o$tke$1@gioia.aioe.org>
<874k89ogte.fsf@bsb.me.uk>
From: NoO...@NoWhere.com (olcott)
In-Reply-To: <874k89ogte.fsf@bsb.me.uk>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <6oudnUgQRd6o9wv8nZ2dnUU7-e2dnZ2d@giganews.com>
Lines: 34
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-xRbx794LrWDuk2mUjQeS0IyQRj2e3JFYTrOvgtcTbzbyc13Hr9q3BsgSg84e3l6fFFltaud6xNdOcs2!GEY8w4Gv73VYY6QUb62i5kE+JgS9xMYoRPo2S7ZPQsyjMotM5UJERx1pRXkI00XBpLh6mGt1zmqm!PQ==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 2486
 by: olcott - Thu, 18 Nov 2021 14:59 UTC

On 11/18/2021 5:15 AM, Ben Bacarisse wrote:
> Juha Nieminen <nospam@thanks.invalid> writes:
>
>> In comp.lang.c++ olcott <NoOne@nowhere.com> wrote:
>>>>> typedef int (*ptr)();
>>>>>
>>>>> int H(ptr x, ptr y)
>>>>> {
>>>>> x(y); // direct execution of P(P)
>>>>> return 1;
>>>>> }
>>>
>>> This code does compile and run correctly.
>>
>> It might compile as C, but it shouldn't compile as C++, because it's trying
>> to call an int(*)() with a parameter, even though that function (that the
>> pointer is pointing to does not take any parameter.)
>
> Just as it must not compile in C++, this code must compile in C. The
> meaning of empty ()s in a function declaration is different between the
> two languages.
>
> When I tidied up the code, I wrote C, not C++, because C has a more
> suitable type available.
>

You did a really great job.

--
Copyright 2021 Pete Olcott

Talent hits a target no one else can hit;
Genius hits a target no one else can see.
Arthur Schopenhauer

Re: Does this program have the specified behavior?

<86y24s7q7i.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Does this program have the specified behavior?
Date: Fri, 10 Dec 2021 01:40:33 -0800
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <86y24s7q7i.fsf@linuxsc.com>
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com> <2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com> <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com> <sn230n$q4t$1@dont-email.me> <3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="94ee63d76223a75d29f96ac519efdd3f";
logging-data="13838"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rRsrdo9uaOcV+PQCP5ldtfC1AHBgyNl0="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:wndgos97MjXJUvXxnxEvbm/arlc=
sha1:Ch9F06xTo/+ejwovMlZ2exfvPl8=
 by: Tim Rentsch - Fri, 10 Dec 2021 09:40 UTC

Mark Bluemel <mark.bluemel@gmail.com> writes:

> On Wednesday, 17 November 2021 at 05:13:08 UTC, Chris M. Thomasson wrote:
>
>> On 11/16/2021 8:46 PM, olcott wrote:
>>
>>> #include <stdint.h>
>>> #include <stdio.h>
>>> typedef int (*ptr)();
>>>
>>> int H(ptr x, ptr y)
>>> {
>>> x(y); // direct execution of P(P)
>>> return 1;
>>> }
>>>
>>> int P(ptr x)
>>> {
>>> H(x, x);
>>> return 1;
>>> }
>>>
>>> int main(void)
>>> {
>>> H(P, P);
>>> }
>>
>> Stack overflow...
>
> Surely a compiler can optimise this to remove the recursion, and
> for that matter, remove any functionality at all, as the code has
> no observable behaviour, as far as I can see (I'd be happy to be
> corrected on this!).

A program that simply does a 'return 0;' from main() does have
observable behavior: it modifies no files (and doesn't perform
any volatile accesses or do any I/O to interactive devices). The
empty set is still a set.

By contrast, a program that sits and does nothing and simply runs
forever does /not/ have observable behavior. The reason is
simple: the predicate condition for what happens with files is
evaluated only at program termination. No termination means no
way to assess observable behavior.

The question of whether the C standard allows (or intends to
allow) the program transformation you describe is a thorny
problem, and not one I'm planning on researching further. But
considering just "observable behavior" in the two cases, ISTM
that the two programs clearly are not identical, because one
does have observable behavior and the other one does not.

Re: Does this program have the specified behavior?

<G7IsJ.152140$831.93@fx40.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx40.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Subject: Re: Does this program have the specified behavior?
Content-Language: en-US
Newsgroups: comp.lang.c
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com> <sn230n$q4t$1@dont-email.me>
<3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com>
<86y24s7q7i.fsf@linuxsc.com>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <86y24s7q7i.fsf@linuxsc.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 63
Message-ID: <G7IsJ.152140$831.93@fx40.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Fri, 10 Dec 2021 07:56:05 -0500
X-Received-Bytes: 3450
 by: Richard Damon - Fri, 10 Dec 2021 12:56 UTC

On 12/10/21 4:40 AM, Tim Rentsch wrote:
> Mark Bluemel <mark.bluemel@gmail.com> writes:
>
>> On Wednesday, 17 November 2021 at 05:13:08 UTC, Chris M. Thomasson wrote:
>>
>>> On 11/16/2021 8:46 PM, olcott wrote:
>>>
>>>> #include <stdint.h>
>>>> #include <stdio.h>
>>>> typedef int (*ptr)();
>>>>
>>>> int H(ptr x, ptr y)
>>>> {
>>>> x(y); // direct execution of P(P)
>>>> return 1;
>>>> }
>>>>
>>>> int P(ptr x)
>>>> {
>>>> H(x, x);
>>>> return 1;
>>>> }
>>>>
>>>> int main(void)
>>>> {
>>>> H(P, P);
>>>> }
>>>
>>> Stack overflow...
>>
>> Surely a compiler can optimise this to remove the recursion, and
>> for that matter, remove any functionality at all, as the code has
>> no observable behaviour, as far as I can see (I'd be happy to be
>> corrected on this!).
>
> A program that simply does a 'return 0;' from main() does have
> observable behavior: it modifies no files (and doesn't perform
> any volatile accesses or do any I/O to interactive devices). The
> empty set is still a set.
>
> By contrast, a program that sits and does nothing and simply runs
> forever does /not/ have observable behavior. The reason is
> simple: the predicate condition for what happens with files is
> evaluated only at program termination. No termination means no
> way to assess observable behavior.
>
> The question of whether the C standard allows (or intends to
> allow) the program transformation you describe is a thorny
> problem, and not one I'm planning on researching further. But
> considering just "observable behavior" in the two cases, ISTM
> that the two programs clearly are not identical, because one
> does have observable behavior and the other one does not.
>

I think the key point is that the infinite recursion means the program
exceeds the environment bounds for defined operation and thus the
behavior of the program has become officially 'Undefined Behavior'. Once
the compiler can see that this will happen, it is freed of all restrictions.

Any observable behavior that would happen before the program enters
Undefined Behavior needs to happen, but there is none, so the compiler,
if it is smart enough to recognize the behavior, is totally free to do
what ever it wants with the program.

Re: Does this program have the specified behavior?

<86czm36nwv.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Does this program have the specified behavior?
Date: Sat, 11 Dec 2021 09:40:00 -0800
Organization: A noiseless patient Spider
Lines: 87
Message-ID: <86czm36nwv.fsf@linuxsc.com>
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com> <2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com> <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com> <sn230n$q4t$1@dont-email.me> <3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com> <86y24s7q7i.fsf@linuxsc.com> <G7IsJ.152140$831.93@fx40.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="601297b613a158a006ae67e40d920115";
logging-data="8919"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mkWovAZsTjagFKyQC+VQUf1Xo4NLfRKc="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:rE2QeSg4IW2Hf8XWU4H0vn24xNk=
sha1:Yv3USijU633H2ZMQnbLjuS+/DyA=
 by: Tim Rentsch - Sat, 11 Dec 2021 17:40 UTC

Richard Damon <Richard@Damon-Family.org> writes:

> On 12/10/21 4:40 AM, Tim Rentsch wrote:
>
>> Mark Bluemel <mark.bluemel@gmail.com> writes:
>>
>>> On Wednesday, 17 November 2021 at 05:13:08 UTC, Chris M. Thomasson wrote:
>>>
>>>> On 11/16/2021 8:46 PM, olcott wrote:
>>>>
>>>>> #include <stdint.h>
>>>>> #include <stdio.h>
>>>>> typedef int (*ptr)();
>>>>>
>>>>> int H(ptr x, ptr y)
>>>>> {
>>>>> x(y); // direct execution of P(P)
>>>>> return 1;
>>>>> }
>>>>>
>>>>> int P(ptr x)
>>>>> {
>>>>> H(x, x);
>>>>> return 1;
>>>>> }
>>>>>
>>>>> int main(void)
>>>>> {
>>>>> H(P, P);
>>>>> }
>>>>
>>>> Stack overflow...
>>>
>>> Surely a compiler can optimise this to remove the recursion, and
>>> for that matter, remove any functionality at all, as the code has
>>> no observable behaviour, as far as I can see (I'd be happy to be
>>> corrected on this!).
>>
>> A program that simply does a 'return 0;' from main() does have
>> observable behavior: it modifies no files (and doesn't perform
>> any volatile accesses or do any I/O to interactive devices). The
>> empty set is still a set.
>>
>> By contrast, a program that sits and does nothing and simply runs
>> forever does /not/ have observable behavior. The reason is
>> simple: the predicate condition for what happens with files is
>> evaluated only at program termination. No termination means no
>> way to assess observable behavior.
>>
>> The question of whether the C standard allows (or intends to
>> allow) the program transformation you describe is a thorny
>> problem, and not one I'm planning on researching further. But
>> considering just "observable behavior" in the two cases, ISTM
>> that the two programs clearly are not identical, because one
>> does have observable behavior and the other one does not.
>
> I think the key point is that the infinite recursion means the
> program exceeds the environment bounds for defined operation and
> thus the behavior of the program has become officially 'Undefined
> Behavior'. [...]

This conclusion isn't right. First, the C standard doesn't
mention any such environmental limit. Second, even if it did,
exceeding an environmental limit doesn't make defined behavior
turn into undefined behavior. Consider the following program:

int
main( void ){
int x;
{{{ .. one billion open braces... {{{
x = 0;
}}} .. one billion close braces.. }}}
return x;
}

An implementation is free to reject this program, but if the
program is accepted it has well-defined semantics, which is
to say its behavior is defined, not undefined. And that is
true regardless of what environmental limits the implementation
may have.

In the context of the C standard, the word "behavior" refers to a
specification, not an action. In other words the "behavior" of
a program is what the program /should/ do, not necessarily what the
program /will/ do, if and when it is executed. A program that just
recurses infinitely has "defined behavior" in the sense that the
C standard uses the term.

Re: Does this program have the specified behavior?

<sp2uoe$q7f$1@z-news.wcss.wroc.pl>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!newsfeed.pionier.net.pl!pwr.wroc.pl!news.wcss.wroc.pl!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.lang.c
Subject: Re: Does this program have the specified behavior?
Date: Sat, 11 Dec 2021 19:38:54 +0000 (UTC)
Organization: Politechnika Wroclawska
Lines: 70
Message-ID: <sp2uoe$q7f$1@z-news.wcss.wroc.pl>
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com> <2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com> <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com> <sn230n$q4t$1@dont-email.me> <3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com> <86y24s7q7i.fsf@linuxsc.com>
NNTP-Posting-Host: hera.math.uni.wroc.pl
X-Trace: z-news.wcss.wroc.pl 1639251534 26863 156.17.86.1 (11 Dec 2021 19:38:54 GMT)
X-Complaints-To: abuse@news.pwr.wroc.pl
NNTP-Posting-Date: Sat, 11 Dec 2021 19:38:54 +0000 (UTC)
Cancel-Lock: sha1:uxg1JI518N2GerSzNc6cE9KyRVI=
User-Agent: tin/2.4.5-20201224 ("Glen Albyn") (Linux/5.10.0-9-amd64 (x86_64))
 by: antis...@math.uni.wroc.pl - Sat, 11 Dec 2021 19:38 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
> Mark Bluemel <mark.bluemel@gmail.com> writes:
>
> > On Wednesday, 17 November 2021 at 05:13:08 UTC, Chris M. Thomasson wrote:
> >
> >> On 11/16/2021 8:46 PM, olcott wrote:
> >>
> >>> #include <stdint.h>
> >>> #include <stdio.h>
> >>> typedef int (*ptr)();
> >>>
> >>> int H(ptr x, ptr y)
> >>> {
> >>> x(y); // direct execution of P(P)
> >>> return 1;
> >>> }
> >>>
> >>> int P(ptr x)
> >>> {
> >>> H(x, x);
> >>> return 1;
> >>> }
> >>>
> >>> int main(void)
> >>> {
> >>> H(P, P);
> >>> }
> >>
> >> Stack overflow...
> >
> > Surely a compiler can optimise this to remove the recursion, and
> > for that matter, remove any functionality at all, as the code has
> > no observable behaviour, as far as I can see (I'd be happy to be
> > corrected on this!).
>
> A program that simply does a 'return 0;' from main() does have
> observable behavior: it modifies no files (and doesn't perform
> any volatile accesses or do any I/O to interactive devices). The
> empty set is still a set.
>
> By contrast, a program that sits and does nothing and simply runs
> forever does /not/ have observable behavior. The reason is
> simple: the predicate condition for what happens with files is
> evaluated only at program termination. No termination means no
> way to assess observable behavior.
>
> The question of whether the C standard allows (or intends to
> allow) the program transformation you describe is a thorny
> problem, and not one I'm planning on researching further. But
> considering just "observable behavior" in the two cases, ISTM
> that the two programs clearly are not identical, because one
> does have observable behavior and the other one does not.

AFAICS currently there is accepted view among theorists that
changing non-terminating behavior into terminating behaviour
is valid program transformation. Concerning C standard
relevant part in N1570 seem to be 5.1.2.3 point 6. IIUC
if program does not terminate on abstract machine clause
about files at program termination is empty: it places no
obligation on implementation. It seems that also clause
about interactive streams places no obligation on
implementation when program performs no I/O. So it seems
that according to N1570 changing non-terminating program
into terminating one is allowed.

At practical level gcc seem to keep infinite loop with empty
body. I can imagine why gcc is doing that...

--
Waldek Hebisch

Re: Does this program have the specified behavior?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Does this program have the specified behavior?
Date: Sat, 11 Dec 2021 16:37:09 -0800
Organization: None to speak of
Lines: 15
Message-ID: <87k0gaacay.fsf@nosuchdomain.example.com>
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
<sn230n$q4t$1@dont-email.me>
<3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com>
<86y24s7q7i.fsf@linuxsc.com> <G7IsJ.152140$831.93@fx40.iad>
<86czm36nwv.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="e677d882c77b218b154f35414bf85b42";
logging-data="10090"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+RQYCZNfCWJCmIenVDepWK"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:EkAC4eND9unN0h+jTSqgUWmQMsA=
sha1:wkSluWd2Oi5Zj++ROdd4BeflNyo=
 by: Keith Thompson - Sun, 12 Dec 2021 00:37 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
[...]
> In the context of the C standard, the word "behavior" refers to a
> specification, not an action. In other words the "behavior" of
> a program is what the program /should/ do, not necessarily what the
> program /will/ do, if and when it is executed.
[...]

The standard's definition of "behavior" is "external appearance or
action".

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

Re: Does this program have the specified behavior?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Does this program have the specified behavior?
Date: Sat, 11 Dec 2021 16:45:08 -0800
Organization: None to speak of
Lines: 40
Message-ID: <87fsqyabxn.fsf@nosuchdomain.example.com>
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com>
<2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com>
<L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com>
<sn230n$q4t$1@dont-email.me>
<3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com>
<86y24s7q7i.fsf@linuxsc.com> <sp2uoe$q7f$1@z-news.wcss.wroc.pl>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="e677d882c77b218b154f35414bf85b42";
logging-data="10090"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19iEuDGoD8Xos8c3IxGiX40"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:d02bJ+QDNILyEk4kpyrlAehn+zs=
sha1:/3yp7+urt0cmHn0vatruAbuW8S4=
 by: Keith Thompson - Sun, 12 Dec 2021 00:45 UTC

antispam@math.uni.wroc.pl writes:
[...]
> AFAICS currently there is accepted view among theorists that
> changing non-terminating behavior into terminating behaviour
> is valid program transformation. Concerning C standard
> relevant part in N1570 seem to be 5.1.2.3 point 6. IIUC
> if program does not terminate on abstract machine clause
> about files at program termination is empty: it places no
> obligation on implementation. It seems that also clause
> about interactive streams places no obligation on
> implementation when program performs no I/O. So it seems
> that according to N1570 changing non-terminating program
> into terminating one is allowed.
>
> At practical level gcc seem to keep infinite loop with empty
> body. I can imagine why gcc is doing that...

N1570 6.8.5p6 is relevant:

An iteration statement whose controlling expression is not a
constant expression, that performs no input/output operations, does
not access volatile objects, and performs no synchronization or
atomic operations in its body, controlling expression, or (in the
case of a for statement) its expression-3, may be assumed by the
implementation to terminate.

with a footnote:

This is intended to allow compiler transformations such as removal
of empty loops even when termination cannot be proven.

This was added in C11.

Personally, I dislike it, partly because it's written in terms of what
the implementation may assume rather than the behavior of a program.

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

Re: Does this program have the specified behavior?

<86wnk969zc.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Does this program have the specified behavior?
Date: Sun, 12 Dec 2021 08:53:11 -0800
Organization: A noiseless patient Spider
Lines: 85
Message-ID: <86wnk969zc.fsf@linuxsc.com>
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com> <2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com> <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com> <sn230n$q4t$1@dont-email.me> <3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com> <86y24s7q7i.fsf@linuxsc.com> <sp2uoe$q7f$1@z-news.wcss.wroc.pl>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="52dee2417da2788e9c7fc8c78c748ef1";
logging-data="30669"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/feDsid5F8QMp6DU63VY/8ZpvH/9axlgc="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:vqfw2RMyElUkvwb7eq2AJk/j0AU=
sha1:X6fYjElY33B05re5JAFLmQM3QUE=
 by: Tim Rentsch - Sun, 12 Dec 2021 16:53 UTC

antispam@math.uni.wroc.pl writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>
>> Mark Bluemel <mark.bluemel@gmail.com> writes:
>>
>>> On Wednesday, 17 November 2021 at 05:13:08 UTC, Chris M. Thomasson wrote:
>>>
>>>> On 11/16/2021 8:46 PM, olcott wrote:
>>>>
>>>>> #include <stdint.h>
>>>>> #include <stdio.h>
>>>>> typedef int (*ptr)();
>>>>>
>>>>> int H(ptr x, ptr y)
>>>>> {
>>>>> x(y); // direct execution of P(P)
>>>>> return 1;
>>>>> }
>>>>>
>>>>> int P(ptr x)
>>>>> {
>>>>> H(x, x);
>>>>> return 1;
>>>>> }
>>>>>
>>>>> int main(void)
>>>>> {
>>>>> H(P, P);
>>>>> }
>>>>
>>>> Stack overflow...
>>>
>>> Surely a compiler can optimise this to remove the recursion, and
>>> for that matter, remove any functionality at all, as the code has
>>> no observable behaviour, as far as I can see (I'd be happy to be
>>> corrected on this!).
>>
>> A program that simply does a 'return 0;' from main() does have
>> observable behavior: it modifies no files (and doesn't perform
>> any volatile accesses or do any I/O to interactive devices). The
>> empty set is still a set.
>>
>> By contrast, a program that sits and does nothing and simply runs
>> forever does /not/ have observable behavior. The reason is
>> simple: the predicate condition for what happens with files is
>> evaluated only at program termination. No termination means no
>> way to assess observable behavior.
>>
>> The question of whether the C standard allows (or intends to
>> allow) the program transformation you describe is a thorny
>> problem, and not one I'm planning on researching further. But
>> considering just "observable behavior" in the two cases, ISTM
>> that the two programs clearly are not identical, because one
>> does have observable behavior and the other one does not.
>
> AFAICS currently there is accepted view among theorists that
> changing non-terminating behavior into terminating behaviour
> is valid program transformation.

The question here concerns only what the C standard does or does
not allow.

> Concerning C standard
> relevant part in N1570 seem to be 5.1.2.3 point 6. IIUC
> if program does not terminate on abstract machine clause
> about files at program termination is empty: it places no
> obligation on implementation.

Changing a program that does not have observable behavior into
one that does have observable behavior is obviously a significant
change.

> It seems that also clause
> about interactive streams places no obligation on
> implementation when program performs no I/O. So it seems
> that according to N1570 changing non-terminating program
> into terminating one is allowed.

A follow-up from Keith Thompson points out N1570 6.8.5p6, which
explicitly allows turning kinds of non-terminating programs into
terminating programs. Since the C standard identifies specific
cases where such a tranformation /is/ allowed, it is reasonable
to infer that they are /not/ allowed in other cases. "The
exception proves the rule, in cases not excepted."

Re: Does this program have the specified behavior?

<86sfux68b2.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Does this program have the specified behavior?
Date: Sun, 12 Dec 2021 09:29:21 -0800
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <86sfux68b2.fsf@linuxsc.com>
References: <TeidndjwvpeU5Qn8nZ2dnUU7-QmdnZ2d@giganews.com> <2ce7a201-45d4-49aa-a512-2ca01a4fbd36n@googlegroups.com> <L6KdnUDjcci1FAn8nZ2dnUU7-V_NnZ2d@giganews.com> <sn230n$q4t$1@dont-email.me> <3e59b2b4-88f9-4bd1-8cf7-eb7baee8c214n@googlegroups.com> <86y24s7q7i.fsf@linuxsc.com> <G7IsJ.152140$831.93@fx40.iad> <86czm36nwv.fsf@linuxsc.com> <87k0gaacay.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="52dee2417da2788e9c7fc8c78c748ef1";
logging-data="27415"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18OsfqlxE52HqucqSccuhiMguHgojnnw2o="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:9Fgj1YCoL1N6QbHsxbN9O+CD9xg=
sha1:zo2I+YxaXpfaqQZAVz0c6qvbNEI=
 by: Tim Rentsch - Sun, 12 Dec 2021 17:29 UTC

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

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> [...]
>
>> In the context of the C standard, the word "behavior" refers to a
>> specification, not an action. In other words the "behavior" of
>> a program is what the program /should/ do, not necessarily what the
>> program /will/ do, if and when it is executed.
>
> [...]
>
> The standard's definition of "behavior" is "external appearance or
> action".

It is. Despite that, in how the C standard uses the term it refers
to a specification for what should happen, not what actually does
happen. A program like this

int
main( void ){
unsigned x = 1;
return x == 0;
}

has defined behavior, whether the program is ever run or not, or
even whether the program is ever compiled. Some text in the C
standard is guilty, to be sure, of some sloppy usage in this
regard, but in context it's clear that "behavior" means a
description or specification of an external appearance or
action, and not an actual appearance or action. For example,
if a program has "undefined behavior", an implementation is
free to do what it chooses. That's a specification of what
appearances or actions are allowed (namely, anything at all),
not a statement of what appearances or actions take place.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor