Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

God requireth not a uniformity of religion. -- Roger Williams


devel / comp.lang.c / Re: Is C ready to become a safer language?

SubjectAuthor
* Is C ready to become a safer language?Thiago Adams
+* Re: Is C ready to become a safer language?Lawrence D'Oliveiro
|+- Re: Is C ready to become a safer language?Kaz Kylheku
|`* Re: Is C ready to become a safer language?Thiago Adams
| +* Re: Is C ready to become a safer language?bart
| |`* Re: Is C ready to become a safer language?Thiago Adams
| | +- Re: Is C ready to become a safer language?Thiago Adams
| | `- Re: Is C ready to become a safer language?Keith Thompson
| `* Re: Is C ready to become a safer language?Keith Thompson
|  `- Re: Is C ready to become a safer language?Thiago Adams
+* Re: Is C ready to become a safer language?Kaz Kylheku
|`- Re: Is C ready to become a safer language?Keith Thompson
+* Re: Is C ready to become a safer language?Keith Thompson
|+* Re: Is C ready to become a safer language?David Brown
||+* Re: Is C ready to become a safer language?Thiago Adams
|||+- Re: Is C ready to become a safer language?Malcolm McLean
|||`* Re: Is C ready to become a safer language?David Brown
||| `* Re: Is C ready to become a safer language?Thiago Adams
|||  `- Re: Is C ready to become a safer language?David Brown
||`* Re: Is C ready to become a safer language?Keith Thompson
|| +* Re: Is C ready to become a safer language?Malcolm McLean
|| |+- Re: Is C ready to become a safer language?Keith Thompson
|| |`* Re: Is C ready to become a safer language?David Brown
|| | `* Re: Is C ready to become a safer language?Malcolm McLean
|| |  +* Re: Is C ready to become a safer language?David Brown
|| |  |+* Re: Is C ready to become a safer language?Malcolm McLean
|| |  ||`- Re: Is C ready to become a safer language?David Brown
|| |  |`* Re: Is C ready to become a safer language?Ben Bacarisse
|| |  | +* Re: Is C ready to become a safer language?Malcolm McLean
|| |  | |+* Re: Is C ready to become a safer language?Ben Bacarisse
|| |  | ||`- Re: Is C ready to become a safer language?Malcolm McLean
|| |  | |`* Re: Is C ready to become a safer language?David Brown
|| |  | | `* ustent on that.Malcolm McLean
|| |  | |  `* Re: ustent on that.David Brown
|| |  | |   `- Re: ustent on that.Malcolm McLean
|| |  | `* Re: Is C ready to become a safer language?bart
|| |  |  `* Re: Is C ready to become a safer language?Ben Bacarisse
|| |  |   `- Re: Is C ready to become a safer language?David Brown
|| |  `- Re: Is C ready to become a safer language?Keith Thompson
|| `* Re: Is C ready to become a safer language?David Brown
||  `* Re: Is C ready to become a safer language?Keith Thompson
||   `- Re: Is C ready to become a safer language?David Brown
|`* Re: Is C ready to become a safer language?Tim Rentsch
| `* Re: Is C ready to become a safer language?Keith Thompson
|  `* Re: Is C ready to become a safer language?Tim Rentsch
|   `* Re: Is C ready to become a safer language?Keith Thompson
|    `* Re: Is C ready to become a safer language?Tim Rentsch
|     `* Re: Is C ready to become a safer language?Keith Thompson
|      `- Re: Is C ready to become a safer language?Tim Rentsch
+* Re: Is C ready to become a safer language?Richard Kettlewell
|`- Re: Is C ready to become a safer language?Thiago Adams
`* Re: Is C ready to become a safer language?bart
 `* Re: Is C ready to become a safer language?Tim Rentsch
  `* Re: Is C ready to become a safer language?bart
   +- Re: Is C ready to become a safer language?Richard Harnden
   +* Re: Is C ready to become a safer language?Kaz Kylheku
   |+* Re: Is C ready to become a safer language?Thiago Adams
   ||`* Re: Is C ready to become a safer language?David Brown
   || `* Re: Is C ready to become a safer language?Thiago Adams
   ||  +- Re: Is C ready to become a safer language?Keith Thompson
   ||  `- Re: Is C ready to become a safer language?David Brown
   |`* Re: Is C ready to become a safer language?bart
   | +- Re: Is C ready to become a safer language?Keith Thompson
   | +* Re: Is C ready to become a safer language?Kaz Kylheku
   | |`* Re: Is C ready to become a safer language?bart
   | | +- Re: Is C ready to become a safer language?David Brown
   | | `- Re: Is C ready to become a safer language?Kaz Kylheku
   | `- Re: Is C ready to become a safer language?David Brown
   +* Re: Is C ready to become a safer language?Keith Thompson
   |`* Re: Is C ready to become a safer language?Thiago Adams
   | `- Re: Is C ready to become a safer language?Keith Thompson
   +* Re: Is C ready to become a safer language?vallor
   |+- Re: Is C ready to become a safer language?bart
   |+* Re: Is C ready to become a safer language?Keith Thompson
   ||`- Re: Is C ready to become a safer language?David Brown
   |+* Re: Is C ready to become a safer language?Tim Rentsch
   ||`- Re: Is C ready to become a safer language?vallor
   |`* Re: Is C ready to become a safer language?Malcolm McLean
   | `* Re: Is C ready to become a safer language?Richard Harnden
   |  `* Re: Is C ready to become a safer language?bart
   |   `* Re: Is C ready to become a safer language?Richard Harnden
   |    `- Re: Is C ready to become a safer language?bart
   `- Re: Is C ready to become a safer language?Tim Rentsch

Pages:1234
Re: Is C ready to become a safer language?

<uq4jca$2h9hc$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 08:14:18 +0100
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <uq4jca$2h9hc$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 9 Feb 2024 07:14:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2ac7bc3d44bf8717c1088c337fb68b71";
logging-data="2663980"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bGOrGl0dQkEltf439uydF7pDousjx5pA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:6dsrYR34Yp9LKiVAZ71QlZ5zgX4=
Content-Language: en-GB
In-Reply-To: <87bk8rgcy0.fsf@nosuchdomain.example.com>
 by: David Brown - Fri, 9 Feb 2024 07:14 UTC

On 08/02/2024 17:04, Keith Thompson wrote:
> David Brown <david.brown@hesbynett.no> writes:
>> On 08/02/2024 05:59, Keith Thompson wrote:
>>> Thiago Adams <thiago.adams@gmail.com> writes:
>>>> Let's say C compilers can detect all sorts of bugs at compile time.
>>>>
>>>> How would C compilers report that? As an error or a warning?
>>>>
>>>> Let's use this sample:
>>>>
>>>> int main() {
>>>> int a = 1;
>>>> a = a / 0;
>>>> }
>>>>
>>>> GCC says:
>>>>
>>>> warning: division by zero is undefined [-Wdivision-by-zero]
>>>> 5 | a = a / 0;
>>>> | ^ ~
>>>>
>>>> In case GCC or any other compiler reports this as an error, then C
>>>> programmers would likely complain. Am I right?
>>> Someone will always complain, but a conforming compiler can report
>>> this as a fatal error.
>>
>> I'm not /entirely/ convinced. Such code is only undefined behaviour
>> at run-time, I believe. A compiler could reject the code (give a
>> fatal error) if it is sure that this will be reached when the code is
>> run. But can it be sure of that, even if it is in "main()" ?
>> Freestanding implementations don't need to run "main()" (not all my
>> programs have had a "main()" function), and the freestanding/hosted
>> implementation choice is a matter of the implementation, not just the
>> compiler.
>
> In a freestanding implementation, main() *might* be just another
> function. In that case a compiler can't prove that the code will be
> invoked.
>
> I was assuming a hosted implementation -- and the compiler knows whether
> its implementation is hosted or freestanding.
>

It's reasonable to assume "hosted" unless you have particular reason not to.

But I am not sure that the /compiler/ knows that it is compiling for a
hosted or freestanding implementation. The same gcc can be used for
Linux hosted user code and a freestanding Linux kernel. Does the
compiler always know which when compiling a unit that happens to contain
"main()" ? I don't think gcc's "-ffreestanding" or "-fno-hosted" flags
are much used - after all, virtually every freestanding C implementation
also implements at least a fair part of the C standard library, and
implements the same semantics in the functions it provides, so there
really is no difference for the compiler.

(This is not something I claim to have any kind of clear answer for -
it's an open question for my part.)

Re: Is C ready to become a safer language?

<uq4jm5$2h9hc$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 08:19:33 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <uq4jm5$2h9hc$2@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 9 Feb 2024 07:19:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2ac7bc3d44bf8717c1088c337fb68b71";
logging-data="2663980"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/y7EJnUIerH3NVpxwiT0Q8UVKfCeHr1yM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:iLqba31oQ00UGhsGUfN/XWVZ1hc=
In-Reply-To: <uq2um0$21dgh$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Fri, 9 Feb 2024 07:19 UTC

On 08/02/2024 17:14, Malcolm McLean wrote:
> On 08/02/2024 16:04, Keith Thompson wrote:

>> In a freestanding implementation, main() *might* be just another
>> function.  In that case a compiler can't prove that the code will be
>> invoked.
>>
> Well sometimes it can. The boot routine or program entry point is by
> defintion always invoked, and you can generally prove that at least some
> code is always reached from that. However it is the halting problem, and
> you can never prove for all cases, even if the code must be reached or
> not reached regardless of runtime inputs.
>

It is not "the halting problem". What you are trying to say, is that it
is undecidable or not a computable problem in the general case.

Compilers and linkers can - and do - map potential reachability, erring
on the side of false positives. It is very common, at least in embedded
systems where you try to avoid wasting space, to trace reachability and
discard code and data that is known to never be reachable. But this is
done by treating any symbol referenced by each function (after dead-code
elimination) as being reachable by that function, which may include
false positives.

Re: Is C ready to become a safer language?

<uq4l7p$2hik2$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: malcolm....@gmail.com (Malcolm McLean)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 07:46:01 +0000
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <uq4l7p$2hik2$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 9 Feb 2024 07:46:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1670c388a502905c76c2cac209d9c149";
logging-data="2673282"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IdcQntVA7rXGeM6NSdP9OQzGtCnObnaQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:xF8RzNzA5SZogWjpO/k3T9MLS4I=
Content-Language: en-GB
In-Reply-To: <uq4jm5$2h9hc$2@dont-email.me>
 by: Malcolm McLean - Fri, 9 Feb 2024 07:46 UTC

On 09/02/2024 07:19, David Brown wrote:
> On 08/02/2024 17:14, Malcolm McLean wrote:
>> On 08/02/2024 16:04, Keith Thompson wrote:
>
>>> In a freestanding implementation, main() *might* be just another
>>> function.  In that case a compiler can't prove that the code will be
>>> invoked.
>>>
>> Well sometimes it can. The boot routine or program entry point is by
>> defintion always invoked, and you can generally prove that at least
>> some code is always reached from that. However it is the halting
>> problem, and you can never prove for all cases, even if the code must
>> be reached or not reached regardless of runtime inputs.
>>
>
> It is not "the halting problem".  What you are trying to say, is that it
> is undecidable or not a computable problem in the general case.
>
The "is this code reached?" problem is the halting problem with the
trivial and unimportant difference that the code in question does not
have to be "exit()".

--
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm

Re: Is C ready to become a safer language?

<uq4o03$2hive$7@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 09:33:07 +0100
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <uq4o03$2hive$7@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me> <uq4l7p$2hik2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 9 Feb 2024 08:33:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9c8bd9f8f89cf9a03af351ae8d81a71b";
logging-data="2673646"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/iRCD2gFUKi6O6U9fcKpwDapcBm4m3008="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:2GgySLfUUcxENZKxayXAOGczXn4=
Content-Language: en-GB
In-Reply-To: <uq4l7p$2hik2$1@dont-email.me>
 by: David Brown - Fri, 9 Feb 2024 08:33 UTC

On 09/02/2024 08:46, Malcolm McLean wrote:
> On 09/02/2024 07:19, David Brown wrote:
>> On 08/02/2024 17:14, Malcolm McLean wrote:
>>> On 08/02/2024 16:04, Keith Thompson wrote:
>>
>>>> In a freestanding implementation, main() *might* be just another
>>>> function.  In that case a compiler can't prove that the code will be
>>>> invoked.
>>>>
>>> Well sometimes it can. The boot routine or program entry point is by
>>> defintion always invoked, and you can generally prove that at least
>>> some code is always reached from that. However it is the halting
>>> problem, and you can never prove for all cases, even if the code must
>>> be reached or not reached regardless of runtime inputs.
>>>
>>
>> It is not "the halting problem".  What you are trying to say, is that
>> it is undecidable or not a computable problem in the general case.
>>
> The "is this code reached?" problem is the halting problem with the
> trivial and unimportant difference that the code in question does not
> have to be "exit()".
>

No, it is not.

The two problems can be shown to be equivalently "hard" - that is, if
you could find a solution to one, it would let you solve the other. But
that does not make them the same problem.

And even if they /were/ the same thing, writing "this is undecidable" or
"this is infeasible to compute" is clear and to the point. Writing
"this is the halting problem" is name-dropping a computer science theory
in order to look smart - and like most such attempts, is more smart-arse
than smart.

Re: Is C ready to become a safer language?

<uq4t8r$2iol4$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: malcolm....@gmail.com (Malcolm McLean)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 10:03:07 +0000
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <uq4t8r$2iol4$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me> <uq4l7p$2hik2$1@dont-email.me>
<uq4o03$2hive$7@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 9 Feb 2024 10:03:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1670c388a502905c76c2cac209d9c149";
logging-data="2712228"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FS8KFmTAEeqKJNlNj5ASRLZrugtB7MNU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:UAZNPKeX8mW7ULKgIQV6DUVpk/s=
Content-Language: en-GB
In-Reply-To: <uq4o03$2hive$7@dont-email.me>
 by: Malcolm McLean - Fri, 9 Feb 2024 10:03 UTC

On 09/02/2024 08:33, David Brown wrote:
> On 09/02/2024 08:46, Malcolm McLean wrote:
>> On 09/02/2024 07:19, David Brown wrote:
>>> On 08/02/2024 17:14, Malcolm McLean wrote:
>>>> On 08/02/2024 16:04, Keith Thompson wrote:
>>>
>>>>> In a freestanding implementation, main() *might* be just another
>>>>> function.  In that case a compiler can't prove that the code will be
>>>>> invoked.
>>>>>
>>>> Well sometimes it can. The boot routine or program entry point is by
>>>> defintion always invoked, and you can generally prove that at least
>>>> some code is always reached from that. However it is the halting
>>>> problem, and you can never prove for all cases, even if the code
>>>> must be reached or not reached regardless of runtime inputs.
>>>>
>>>
>>> It is not "the halting problem".  What you are trying to say, is that
>>> it is undecidable or not a computable problem in the general case.
>>>
>> The "is this code reached?" problem is the halting problem with the
>> trivial and unimportant difference that the code in question does not
>> have to be "exit()".
>>
>
> No, it is not.
>
> The two problems can be shown to be equivalently "hard" - that is, if
> you could find a solution to one, it would let you solve the other.  But
> that does not make them the same problem.
>
> And even if they /were/ the same thing, writing "this is undecidable" or
> "this is infeasible to compute" is clear and to the point.  Writing
> "this is the halting problem" is name-dropping a computer science theory
> in order to look smart - and like most such attempts, is more smart-arse
> than smart.
>
Well I've been accused of wasting my English degree, and so now I'm
going to accuse you of wasting your mathematics-related degree.
--
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm

Re: Is C ready to become a safer language?

<uq4u4j$2iv0k$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 11:17:54 +0100
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <uq4u4j$2iv0k$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me> <uq4l7p$2hik2$1@dont-email.me>
<uq4o03$2hive$7@dont-email.me> <uq4t8r$2iol4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 9 Feb 2024 10:17:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9c8bd9f8f89cf9a03af351ae8d81a71b";
logging-data="2718740"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vllCgbaWPY6lzIQYEu+xuZhbGAMsUlxE="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:Gz2mKbMPe64kkSDwPBun6K+WKXQ=
Content-Language: en-GB
In-Reply-To: <uq4t8r$2iol4$1@dont-email.me>
 by: David Brown - Fri, 9 Feb 2024 10:17 UTC

On 09/02/2024 11:03, Malcolm McLean wrote:
> On 09/02/2024 08:33, David Brown wrote:
>> On 09/02/2024 08:46, Malcolm McLean wrote:
>>> On 09/02/2024 07:19, David Brown wrote:
>>>> On 08/02/2024 17:14, Malcolm McLean wrote:
>>>>> On 08/02/2024 16:04, Keith Thompson wrote:
>>>>
>>>>>> In a freestanding implementation, main() *might* be just another
>>>>>> function.  In that case a compiler can't prove that the code will be
>>>>>> invoked.
>>>>>>
>>>>> Well sometimes it can. The boot routine or program entry point is
>>>>> by defintion always invoked, and you can generally prove that at
>>>>> least some code is always reached from that. However it is the
>>>>> halting problem, and you can never prove for all cases, even if the
>>>>> code must be reached or not reached regardless of runtime inputs.
>>>>>
>>>>
>>>> It is not "the halting problem".  What you are trying to say, is
>>>> that it is undecidable or not a computable problem in the general case.
>>>>
>>> The "is this code reached?" problem is the halting problem with the
>>> trivial and unimportant difference that the code in question does not
>>> have to be "exit()".
>>>
>>
>> No, it is not.
>>
>> The two problems can be shown to be equivalently "hard" - that is, if
>> you could find a solution to one, it would let you solve the other.
>> But that does not make them the same problem.
>>
>> And even if they /were/ the same thing, writing "this is undecidable"
>> or "this is infeasible to compute" is clear and to the point.  Writing
>> "this is the halting problem" is name-dropping a computer science
>> theory in order to look smart - and like most such attempts, is more
>> smart-arse than smart.
>>
> Well I've been accused of wasting my English degree, and so now I'm
> going to accuse you of wasting your mathematics-related degree.

I haven't seen anyone here accusing you of wasting your English
literature degree. I think you have a lot of trouble communicating with
others here, and I think you have a strong tendency to invent what you
think others might have written, rather than reading what they actually
wrote. It is not helped by your "slapdash" style. I would have
expected someone with a university level degree in English to have a
greater emphasis on reading and understanding, and communicating.

But that does not mean I could or did accuse you of wasting your degree.
I don't know nearly enough about your life to comment on that. If you
are where you are now, and if your career, hobbies, interests,
education, or anything else in your life has benefited from the degree,
then it was not wasted.

I studied mathematics and computation. Both have been very useful in my
work. I can't claim that much of the high-level mathematics is directly
applicable to my job, but the training in logical thinking, problem
solving, and an emphasis on proof is vital. In addition, I was lucky
enough to have a tutor that put a lot of weight on communication and
accurate technical writing, which is an essential part of my job.

Re: Is C ready to become a safer language?

<8734u2q6k6.fsf@bsb.me.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 09 Feb 2024 10:24:09 +0000
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <8734u2q6k6.fsf@bsb.me.uk>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com>
<uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com>
<uq2um0$21dgh$1@dont-email.me> <uq4jm5$2h9hc$2@dont-email.me>
<uq4l7p$2hik2$1@dont-email.me> <uq4o03$2hive$7@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="c235c3c701c62e624897d4b41eb7a3c2";
logging-data="2709440"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LLPg3/zblNf0p2ghtmahWhBbKTBSg92o="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:6404DdkPPnCeoyR7ZUvaZNE68Ss=
sha1:ZZQ9t3qHWpl2BeCuGBDXZjgZEzE=
X-BSB-Auth: 1.befe189ed7c466ac9232.20240209102409GMT.8734u2q6k6.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 9 Feb 2024 10:24 UTC

David Brown <david.brown@hesbynett.no> writes:

> On 09/02/2024 08:46, Malcolm McLean wrote:
>> On 09/02/2024 07:19, David Brown wrote:
>>> On 08/02/2024 17:14, Malcolm McLean wrote:
>>>> On 08/02/2024 16:04, Keith Thompson wrote:
>>>
>>>>> In a freestanding implementation, main() *might* be just another
>>>>> function.  In that case a compiler can't prove that the code will be
>>>>> invoked.
>>>>>
>>>> Well sometimes it can. The boot routine or program entry point is by
>>>> defintion always invoked, and you can generally prove that at least
>>>> some code is always reached from that. However it is the halting
>>>> problem, and you can never prove for all cases, even if the code must
>>>> be reached or not reached regardless of runtime inputs.
>>>>
>>>
>>> It is not "the halting problem".  What you are trying to say, is that it
>>> is undecidable or not a computable problem in the general case.
>>>
>> The "is this code reached?" problem is the halting problem with the
>> trivial and unimportant difference that the code in question does not
>> have to be "exit()".
>
> No, it is not.
>
> The two problems can be shown to be equivalently "hard" - that is, if you
> could find a solution to one, it would let you solve the other. But that
> does not make them the same problem.

Sure. But it's not the halting problem for another reason as well.

In the formal models (that have halting problems and so on), it's "the
computation" that is the problem instance. That is, the code and all
the data are presented for an answer. A C compiler has to decide on
reachability without knowing the input.

For example, is this code "undefined":

int c, freq[128];
while ((c = getchar()) != EOF) freq[c]++;

? Maybe it was knocked up as a quick way to collect stats on base64
encoded data streams. If so, it's fine (at least in terms of UB).

--
Ben.

Re: Is C ready to become a safer language?

<uq521h$2jk0f$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: malcolm....@gmail.com (Malcolm McLean)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 11:24:31 +0000
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <uq521h$2jk0f$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me> <uq4l7p$2hik2$1@dont-email.me>
<uq4o03$2hive$7@dont-email.me> <8734u2q6k6.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 9 Feb 2024 11:24:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1670c388a502905c76c2cac209d9c149";
logging-data="2740239"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+a6yAJRJHyYDFzlbGoAWmaFlmbxVnHo2g="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:VhfE2/SSQ+7F3sbcy3Is0E1/jGg=
Content-Language: en-GB
In-Reply-To: <8734u2q6k6.fsf@bsb.me.uk>
 by: Malcolm McLean - Fri, 9 Feb 2024 11:24 UTC

On 09/02/2024 10:24, Ben Bacarisse wrote:
> David Brown <david.brown@hesbynett.no> writes:
>
>> On 09/02/2024 08:46, Malcolm McLean wrote:
>>> On 09/02/2024 07:19, David Brown wrote:
>>>> On 08/02/2024 17:14, Malcolm McLean wrote:
>>>>> On 08/02/2024 16:04, Keith Thompson wrote:
>>>>
>>>>>> In a freestanding implementation, main() *might* be just another
>>>>>> function.  In that case a compiler can't prove that the code will be
>>>>>> invoked.
>>>>>>
>>>>> Well sometimes it can. The boot routine or program entry point is by
>>>>> defintion always invoked, and you can generally prove that at least
>>>>> some code is always reached from that. However it is the halting
>>>>> problem, and you can never prove for all cases, even if the code must
>>>>> be reached or not reached regardless of runtime inputs.
>>>>>
>>>>
>>>> It is not "the halting problem".  What you are trying to say, is that it
>>>> is undecidable or not a computable problem in the general case.
>>>>
>>> The "is this code reached?" problem is the halting problem with the
>>> trivial and unimportant difference that the code in question does not
>>> have to be "exit()".
>>
>> No, it is not.
>>
>> The two problems can be shown to be equivalently "hard" - that is, if you
>> could find a solution to one, it would let you solve the other. But that
>> does not make them the same problem.
>
> Sure. But it's not the halting problem for another reason as well.
>
> In the formal models (that have halting problems and so on), it's "the
> computation" that is the problem instance. That is, the code and all
> the data are presented for an answer. A C compiler has to decide on
> reachability without knowing the input.
>
> For example, is this code "undefined":
>
> int c, freq[128];
> while ((c = getchar()) != EOF) freq[c]++;
>
> ? Maybe it was knocked up as a quick way to collect stats on base64
> encoded data streams. If so, it's fine (at least in terms of UB).
>
Yes, but I specified "regardless of runtime inputs". A bit downthread,
you can be forgiven for having missed that. But DB less so, especially
when I'm accused of being the one who doesn't read things properly. And
even when I agree there might be some truth in that, and explain why, I
am then accused of misrepresenting what an Oxford English degree is like.
If you change the halting problem such that some of the symbols on the
tape are allowed to have unknown values then I don't think you are
changing it in any mathematically very interesting way so it is still
"trival", but if you attempt a halt decider it will substantially change
your programming approach, and so it is no longer "unimportant".

If a signed integer overflows the behaviour is undefined, so you also
have to prove that the input stream is short. And of course you also
forgot to intialise to zero.
--
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm

Re: Is C ready to become a safer language?

<uq56pm$2kbv7$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 12:45:42 +0000
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <uq56pm$2kbv7$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me> <uq4l7p$2hik2$1@dont-email.me>
<uq4o03$2hive$7@dont-email.me> <8734u2q6k6.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 9 Feb 2024 12:45:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7249358d931a886a5d72096d92eeb1eb";
logging-data="2764775"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GPqudB42toWZnmJhjyUPryDPDKltSbpY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:K5y43KIvMertM2EzCRRNnUO37a4=
Content-Language: en-GB
In-Reply-To: <8734u2q6k6.fsf@bsb.me.uk>
 by: bart - Fri, 9 Feb 2024 12:45 UTC

On 09/02/2024 10:24, Ben Bacarisse wrote:
> David Brown <david.brown@hesbynett.no> writes:
>
>> On 09/02/2024 08:46, Malcolm McLean wrote:

>> The two problems can be shown to be equivalently "hard" - that is, if you
>> could find a solution to one, it would let you solve the other. But that
>> does not make them the same problem.
>
> Sure. But it's not the halting problem for another reason as well.
>
> In the formal models (that have halting problems and so on), it's "the
> computation" that is the problem instance. That is, the code and all
> the data are presented for an answer. A C compiler has to decide on
> reachability without knowing the input.
>
> For example, is this code "undefined":
>
> int c, freq[128];
> while ((c = getchar()) != EOF) freq[c]++;
>
> ? Maybe it was knocked up as a quick way to collect stats on base64
> encoded data streams. If so, it's fine (at least in terms of UB).

Perhaps until you read an input that has 2**31 or more of the same
character.

Re: Is C ready to become a safer language?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 09 Feb 2024 13:01:59 +0000
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <87wmrdpz94.fsf@bsb.me.uk>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com>
<uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com>
<uq2um0$21dgh$1@dont-email.me> <uq4jm5$2h9hc$2@dont-email.me>
<uq4l7p$2hik2$1@dont-email.me> <uq4o03$2hive$7@dont-email.me>
<8734u2q6k6.fsf@bsb.me.uk> <uq56pm$2kbv7$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="c235c3c701c62e624897d4b41eb7a3c2";
logging-data="2767696"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/NIRHjH5hQ+VXAJ0bJKFyx99lKSVQEgwI="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:BXKlBWGqs7wM3rJqJvZ9h3Uv8OU=
sha1:M7cltG1zE8URKSMS/MJUo13jg5Y=
X-BSB-Auth: 1.768b998c1967e45b0187.20240209130159GMT.87wmrdpz94.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 9 Feb 2024 13:01 UTC

bart <bc@freeuk.com> writes:

> On 09/02/2024 10:24, Ben Bacarisse wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>
>>> On 09/02/2024 08:46, Malcolm McLean wrote:
>
>>> The two problems can be shown to be equivalently "hard" - that is, if you
>>> could find a solution to one, it would let you solve the other. But that
>>> does not make them the same problem.
>> Sure. But it's not the halting problem for another reason as well.
>> In the formal models (that have halting problems and so on), it's "the
>> computation" that is the problem instance. That is, the code and all
>> the data are presented for an answer. A C compiler has to decide on
>> reachability without knowing the input.
>> For example, is this code "undefined":
>> int c, freq[128];
>> while ((c = getchar()) != EOF) freq[c]++;
>> ? Maybe it was knocked up as a quick way to collect stats on base64
>> encoded data streams. If so, it's fine (at least in terms of UB).
>
> Perhaps until you read an input that has 2**31 or more of the same
> character.

Yes, that's the point. Any UB is dependent on the input. It's not a
static property of the code.

--
Ben.

Re: Is C ready to become a safer language?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 09 Feb 2024 13:28:18 +0000
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <87fry1py19.fsf@bsb.me.uk>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com>
<uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com>
<uq2um0$21dgh$1@dont-email.me> <uq4jm5$2h9hc$2@dont-email.me>
<uq4l7p$2hik2$1@dont-email.me> <uq4o03$2hive$7@dont-email.me>
<8734u2q6k6.fsf@bsb.me.uk> <uq521h$2jk0f$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="c235c3c701c62e624897d4b41eb7a3c2";
logging-data="2787489"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18X/+0ucL1nprbIIOXRNQ7Rhv1eGFUy0jg="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:FZysVCWl+A0XGVm450i5jnrYu5Y=
sha1:cgQpoThE1TxjGl135QDC9x07Dyo=
X-BSB-Auth: 1.2535a0ddbeebb98b4855.20240209132818GMT.87fry1py19.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 9 Feb 2024 13:28 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On 09/02/2024 10:24, Ben Bacarisse wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>
>>> On 09/02/2024 08:46, Malcolm McLean wrote:
>>>> On 09/02/2024 07:19, David Brown wrote:
>>>>> On 08/02/2024 17:14, Malcolm McLean wrote:
>>>>>> On 08/02/2024 16:04, Keith Thompson wrote:
>>>>>
>>>>>>> In a freestanding implementation, main() *might* be just another
>>>>>>> function.  In that case a compiler can't prove that the code will be
>>>>>>> invoked.
>>>>>>>
>>>>>> Well sometimes it can. The boot routine or program entry point is by
>>>>>> defintion always invoked, and you can generally prove that at least
>>>>>> some code is always reached from that. However it is the halting
>>>>>> problem, and you can never prove for all cases, even if the code must
>>>>>> be reached or not reached regardless of runtime inputs.
>>>>>>
>>>>>
>>>>> It is not "the halting problem".  What you are trying to say, is that it
>>>>> is undecidable or not a computable problem in the general case.
>>>>>
>>>> The "is this code reached?" problem is the halting problem with the
>>>> trivial and unimportant difference that the code in question does not
>>>> have to be "exit()".
>>>
>>> No, it is not.
>>>
>>> The two problems can be shown to be equivalently "hard" - that is, if you
>>> could find a solution to one, it would let you solve the other. But that
>>> does not make them the same problem.
>> Sure. But it's not the halting problem for another reason as well.
>> In the formal models (that have halting problems and so on), it's "the
>> computation" that is the problem instance. That is, the code and all
>> the data are presented for an answer. A C compiler has to decide on
>> reachability without knowing the input.
>> For example, is this code "undefined":
>> int c, freq[128];
>> while ((c = getchar()) != EOF) freq[c]++;
>> ? Maybe it was knocked up as a quick way to collect stats on base64
>> encoded data streams. If so, it's fine (at least in terms of UB).
>>
> Yes, but I specified "regardless of runtime inputs".

How can it be the halting problem "regardless of runtime inputs"
considering my point that the HP instances include the input? You may
be thinking of the universal halting problem, but that does not really
fit what you said.

A better way to put it would be just to state that almost all
interesting run-time properties of programs are undecidable. And Rice's
theorem gives any one who is curious the exact definition of
"interesting".

> If a signed integer overflows the behaviour is undefined, so you also have
> to prove that the input stream is short. And of course you also forgot to
> intialise to zero.

I did indeed. Thanks. Overflow is just another example of the point I
was making, but not zeroing wasn't!

--
Ben.

Re: Is C ready to become a safer language?

<uq5bbo$2lhsv$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 15:03:36 +0100
Organization: A noiseless patient Spider
Lines: 96
Message-ID: <uq5bbo$2lhsv$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me> <uq4l7p$2hik2$1@dont-email.me>
<uq4o03$2hive$7@dont-email.me> <8734u2q6k6.fsf@bsb.me.uk>
<uq521h$2jk0f$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 9 Feb 2024 14:03:36 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9c8bd9f8f89cf9a03af351ae8d81a71b";
logging-data="2803615"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18e6kG37hbRcCHu4TCTGC7+Wsd2tfYZjOU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:3CWF64svJFltJJhmr9s3zd2IjMY=
Content-Language: en-GB
In-Reply-To: <uq521h$2jk0f$1@dont-email.me>
 by: David Brown - Fri, 9 Feb 2024 14:03 UTC

On 09/02/2024 12:24, Malcolm McLean wrote:
> On 09/02/2024 10:24, Ben Bacarisse wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>
>>> On 09/02/2024 08:46, Malcolm McLean wrote:
>>>> On 09/02/2024 07:19, David Brown wrote:
>>>>> On 08/02/2024 17:14, Malcolm McLean wrote:
>>>>>> On 08/02/2024 16:04, Keith Thompson wrote:
>>>>>
>>>>>>> In a freestanding implementation, main() *might* be just another
>>>>>>> function.  In that case a compiler can't prove that the code will be
>>>>>>> invoked.
>>>>>>>
>>>>>> Well sometimes it can. The boot routine or program entry point is by
>>>>>> defintion always invoked, and you can generally prove that at least
>>>>>> some code is always reached from that. However it is the halting
>>>>>> problem, and you can never prove for all cases, even if the code must
>>>>>> be reached or not reached regardless of runtime inputs.
>>>>>>
>>>>>
>>>>> It is not "the halting problem".  What you are trying to say, is
>>>>> that it
>>>>> is undecidable or not a computable problem in the general case.
>>>>>
>>>> The "is this code reached?" problem is the halting problem with the
>>>> trivial and unimportant difference that the code in question does not
>>>> have to be "exit()".
>>>
>>> No, it is not.
>>>
>>> The two problems can be shown to be equivalently "hard" - that is, if
>>> you
>>> could find a solution to one, it would let you solve the other.  But
>>> that
>>> does not make them the same problem.
>>
>> Sure.  But it's not the halting problem for another reason as well.
>>
>> In the formal models (that have halting problems and so on), it's "the
>> computation" that is the problem instance.  That is, the code and all
>> the data are presented for an answer.  A C compiler has to decide on
>> reachability without knowing the input.
>>
>> For example, is this code "undefined":
>>
>>    int c, freq[128];
>>    while ((c = getchar()) != EOF) freq[c]++;
>>
>> ?  Maybe it was knocked up as a quick way to collect stats on base64
>> encoded data streams.  If so, it's fine (at least in terms of UB).
>>
> Yes, but I specified "regardless of runtime inputs". A bit downthread,
> you can be forgiven for having missed that. But DB less so, especially
> when I'm accused of being the one who doesn't read things properly.

Why should I be "forgiven" for missing that, when I did not miss it and
when it is not at all relevant to what I wrote? I saw it, but responded
only to the clear bit of your claim "it is the halting problem", and
ignored the jumbled part about "runtime inputs". My point stands
whatever you meant to say about runtime inputs, and however what you
meant relates to what you tried to write.

So again, you did not read my post, or you are bizarrely blaming /me/
for something you think Ben did.

> And
> even when I agree there might be some truth in that, and explain why, I
> am then accused of misrepresenting what an Oxford English degree is like.

Again, read my posts. I said your description of your degree does not
match my experience with my own degree at Oxford, nor what I heard from
others at the time who studied English literature. You may have given
an accurate description of your personal experiences - I have no way to
either prove or disprove that, and no reason to suspect you of being
intentionally deceptive. But I believe it to have been unusual, and due
to a bad tutor.

> If you change the halting problem such that some of the symbols on the
> tape are allowed to have unknown values then I don't think you are
> changing it in any mathematically very interesting way so it is still
> "trival", but if you attempt a halt decider it will substantially change
> your programming approach, and so it is no longer "unimportant".
>

I would prefer to think a bit about how a volatile input tape would
relate to the halting problem as it is normally stated, before offering
an opinion on how it may or may not change the result. I suspect you
are correct that it will not change the problem or the results, but I
would want to be a bit more rigorous about what is meant before jumping
to conclusions.

However, I have no idea what you mean by "if you attempt a halt decider
it will substantially change your programming approach".

Re: Is C ready to become a safer language?

<uq5bd6$2lisf$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!newsfeed.endofthelinebbs.com!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: malcolm....@gmail.com (Malcolm McLean)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 14:04:21 +0000
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <uq5bd6$2lisf$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me> <uq4l7p$2hik2$1@dont-email.me>
<uq4o03$2hive$7@dont-email.me> <8734u2q6k6.fsf@bsb.me.uk>
<uq521h$2jk0f$1@dont-email.me> <87fry1py19.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 9 Feb 2024 14:04:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1670c388a502905c76c2cac209d9c149";
logging-data="2804623"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/DuZ0SPP9DyI339RoG57XcpB1MmYp06pw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:mOfYNYj7brCojL9lCC2WERGCioc=
In-Reply-To: <87fry1py19.fsf@bsb.me.uk>
Content-Language: en-GB
 by: Malcolm McLean - Fri, 9 Feb 2024 14:04 UTC

On 09/02/2024 13:28, Ben Bacarisse wrote:
> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>
>> On 09/02/2024 10:24, Ben Bacarisse wrote:
>>> David Brown <david.brown@hesbynett.no> writes:
>>>
>>>> On 09/02/2024 08:46, Malcolm McLean wrote:
>>>>> On 09/02/2024 07:19, David Brown wrote:
>>>>>> On 08/02/2024 17:14, Malcolm McLean wrote:
>>>>>>> On 08/02/2024 16:04, Keith Thompson wrote:
>>>>>>
>>>>>>>> In a freestanding implementation, main() *might* be just another
>>>>>>>> function.  In that case a compiler can't prove that the code will be
>>>>>>>> invoked.
>>>>>>>>
>>>>>>> Well sometimes it can. The boot routine or program entry point is by
>>>>>>> defintion always invoked, and you can generally prove that at least
>>>>>>> some code is always reached from that. However it is the halting
>>>>>>> problem, and you can never prove for all cases, even if the code must
>>>>>>> be reached or not reached regardless of runtime inputs.
>>>>>>>
>>>>>>
>>>>>> It is not "the halting problem".  What you are trying to say, is that it
>>>>>> is undecidable or not a computable problem in the general case.
>>>>>>
>>>>> The "is this code reached?" problem is the halting problem with the
>>>>> trivial and unimportant difference that the code in question does not
>>>>> have to be "exit()".
>>>>
>>>> No, it is not.
>>>>
>>>> The two problems can be shown to be equivalently "hard" - that is, if you
>>>> could find a solution to one, it would let you solve the other. But that
>>>> does not make them the same problem.
>>> Sure. But it's not the halting problem for another reason as well.
>>> In the formal models (that have halting problems and so on), it's "the
>>> computation" that is the problem instance. That is, the code and all
>>> the data are presented for an answer. A C compiler has to decide on
>>> reachability without knowing the input.
>>> For example, is this code "undefined":
>>> int c, freq[128];
>>> while ((c = getchar()) != EOF) freq[c]++;
>>> ? Maybe it was knocked up as a quick way to collect stats on base64
>>> encoded data streams. If so, it's fine (at least in terms of UB).
>>>
>> Yes, but I specified "regardless of runtime inputs".
>
> How can it be the halting problem "regardless of runtime inputs"
> considering my point that the HP instances include the input? You may
> be thinking of the universal halting problem, but that does not really
> fit what you said.
>
Most real programs have some runtime data and it is rare to have a
program which is designed to calculate a hardcoded value. But often it
doesn't feed into any branches and so it's quite straightforwards to
show that it won't affect flow control. However this won't help you to
write a "statement reached decider" which works for all cases.
> A better way to put it would be just to state that almost all
> interesting run-time properties of programs are undecidable. And Rice's
> theorem gives any one who is curious the exact definition of
> "interesting".
>
Unlike you I'm not a trained computer scientist and I just pick up bits
as I go along. I'm familiar with Turing's proof that a halt decider is
impossible (how could I not be?), but not so comfortable with Rice's
theorem. So whilst I'm sure your explanation is more general and better,
I could not have made it myself. I do qualify as "curious" however.

--
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm

Re: Is C ready to become a safer language?

<uq5bk0$2lhsv$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 15:08:00 +0100
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <uq5bk0$2lhsv$2@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me> <uq4l7p$2hik2$1@dont-email.me>
<uq4o03$2hive$7@dont-email.me> <8734u2q6k6.fsf@bsb.me.uk>
<uq56pm$2kbv7$1@dont-email.me> <87wmrdpz94.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 9 Feb 2024 14:08:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9c8bd9f8f89cf9a03af351ae8d81a71b";
logging-data="2803615"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iTt8xn8aYwUYvjl/sXsiAjC3S8p+0WR4="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:z2R5J6220BUQMiTeh4uUaULSz8A=
Content-Language: en-GB
In-Reply-To: <87wmrdpz94.fsf@bsb.me.uk>
 by: David Brown - Fri, 9 Feb 2024 14:08 UTC

On 09/02/2024 14:01, Ben Bacarisse wrote:
> bart <bc@freeuk.com> writes:
>
>> On 09/02/2024 10:24, Ben Bacarisse wrote:
>>> David Brown <david.brown@hesbynett.no> writes:
>>>
>>>> On 09/02/2024 08:46, Malcolm McLean wrote:
>>
>>>> The two problems can be shown to be equivalently "hard" - that is, if you
>>>> could find a solution to one, it would let you solve the other. But that
>>>> does not make them the same problem.
>>> Sure. But it's not the halting problem for another reason as well.
>>> In the formal models (that have halting problems and so on), it's "the
>>> computation" that is the problem instance. That is, the code and all
>>> the data are presented for an answer. A C compiler has to decide on
>>> reachability without knowing the input.
>>> For example, is this code "undefined":
>>> int c, freq[128];
>>> while ((c = getchar()) != EOF) freq[c]++;
>>> ? Maybe it was knocked up as a quick way to collect stats on base64
>>> encoded data streams. If so, it's fine (at least in terms of UB).
>>
>> Perhaps until you read an input that has 2**31 or more of the same
>> character.
>
> Yes, that's the point. Any UB is dependent on the input. It's not a
> static property of the code.
>

Well, /some/ UB is determinable at compile time - such as an identifier
having both internal and external linkage in the same unit, and a few
other bits and pieces that the language designers probably thought were
too burdensome to require compiler implementers to handle.

But mostly UB is a runtime issue, and therefore usually it is dependent
on the input.

ustent on that.

<uq5i8r$2mp0a$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.chmurka.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: malcolm....@gmail.com (Malcolm McLean)
Newsgroups: comp.lang.c
Subject: ustent on that.
Date: Fri, 9 Feb 2024 16:01:30 +0000
Organization: A noiseless patient Spider
Lines: 89
Message-ID: <uq5i8r$2mp0a$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me> <uq4l7p$2hik2$1@dont-email.me>
<uq4o03$2hive$7@dont-email.me> <8734u2q6k6.fsf@bsb.me.uk>
<uq521h$2jk0f$1@dont-email.me> <uq5bbo$2lhsv$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 9 Feb 2024 16:01:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1670c388a502905c76c2cac209d9c149";
logging-data="2843658"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ihH0+++V3+HLJ/ZE3BkWjg2vrAfcpjlQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:a6y8/doE+kRuSmzFVDH3vfopIgw=
Content-Language: en-GB
In-Reply-To: <uq5bbo$2lhsv$1@dont-email.me>
 by: Malcolm McLean - Fri, 9 Feb 2024 16:01 UTC

On 09/02/2024 14:03, David Brown wrote:
> On 09/02/2024 12:24, Malcolm McLean wrote:
>>
>> And even when I agree there might be some truth in that, and explain
>> why, I am then accused of misrepresenting what an Oxford English
>> degree is like.
>
> Again, read my posts.  I said your description of your degree does not
> match my experience with my own degree at Oxford, nor what I heard from
> others at the time who studied English literature.  You may have given
> an accurate description of your personal experiences - I have no way to
> either prove or disprove that, and no reason to suspect you of being
> intentionally deceptive.  But I believe it to have been unusual, and due
> to a bad tutor.
>

OK. So you also attended Oxford. And now I'm surprised. That's what
Oxford English is like. Very much an emphasis on geting things done,
quickly and to deadlines, because most Oxford English graduates will
work in careers where that is important. Only a small minority become
computer programmers like me where a program often has t be perfect ot
it doesn't work at all. Now whislt of course I don;t have direct
experience of other colleges, I'm pretty sure my own college was fairly
normal about this. One tutor was maybe a bit keener than normal.
We got essays for next week on an author most of us had never read on
the very first day, and I dn;t think you;f]=d get that at every college.
But not far off.

I'm really not mischaracterising. Of course you also have to defend the
essay and it is marked. But that's less important. It's very unusual to
receive a mark for an essay which is so low that it means that if you
write a similar essay in finals you will fail. Oxford is extremely
generous with the lower marks and in ensuring that they are not a fail.
Unless of course the candidate submits nothing. In which case it can
only be a fail. So you must submit something which constitutes an essay
for the tutorial, and my tutors were very insistent on that.

I fell out with my tutor catastrophically over moral issues and because
of the type of subject English Literature is, that had profound
implications for my work. He allowed that to happen, he was in the wrong
about our dispute and everything I predicted that would happen in
English Studies has in fact come to pass, and he was therefore a bad
tutor. But to be fair I was an extremely difficult student.

>> If you change the halting problem such that some of the symbols on the
>> tape are allowed to have unknown values then I don't think you are
>> changing it in any mathematically very interesting way so it is still
>> "trival", but if you attempt a halt decider it will substantially
>> change your programming approach, and so it is no longer "unimportant".
>>
>
> I would prefer to think a bit about how a volatile input tape would
> relate to the halting problem as it is normally stated, before offering
> an opinion on how it may or may not change the result.  I suspect you
> are correct that it will not change the problem or the results, but I
> would want to be a bit more rigorous about what is meant before jumping
> to conclusions.
>
Well this is it isn't it. Employ a computer scientist as a mathematician
and you'll get a rigorous proof. Employ an English graduate (and I have
actually held the job title "mathematician" though I am in no way
qualified to describe myself as such) and he quickly guesses. But are
you so surprised that you think I am thereby misrepresenting Oxford
English? And the English graduate does at least produce something
constructive quickly.

>
> However, I have no idea what you mean by "if you attempt a halt decider
> it will substantially change your programming approach".
>
We're changing the model slightly so that instead of all the input tape
being available to the decider, some values are unknown. It still has to
determine whether the program will halt or not, and whilst sometimes
this will now be inherently impossible because the answer depends on the
input, often it will not be so. As I said, I don't think anything much
has actually changed. But it does mean that we now have to write our
halt decider in a different way. It's no longer as simple as replacing
the code we want to know is reached by exit() and declaring that it is
now the halting problem.

The halt decider will fail to work as specified on some inputs, so I say
"attempt a halt decider". You can have a go. But it won't actually work.

--
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm

Re: Is C ready to become a safer language?

<8734u1fvqf.fsf@nosuchdomain.example.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.bbs.nz!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 09 Feb 2024 08:28:08 -0800
Organization: None to speak of
Lines: 14
Message-ID: <8734u1fvqf.fsf@nosuchdomain.example.com>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com>
<uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com>
<uq4jca$2h9hc$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="639f38d912c33920e0e5a36e0f09675f";
logging-data="2845310"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GmgfBd4RGcKtozAHG6mT/"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:873ACExkpmkoJ6l/KYQXuwZdvis=
sha1:6ERvJlg/AEpMQZndMIeL9xLyRJY=
 by: Keith Thompson - Fri, 9 Feb 2024 16:28 UTC

David Brown <david.brown@hesbynett.no> writes:
[...]
> But I am not sure that the /compiler/ knows that it is compiling for a
> hosted or freestanding implementation. The same gcc can be used for
> Linux hosted user code and a freestanding Linux kernel.
[...]

A conforming compiler must predefine the macro __STDC_HOSTED__ to either
0 or 1 (since C99).

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

Re: Is C ready to become a safer language?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 09 Feb 2024 08:48:41 -0800
Organization: None to speak of
Lines: 66
Message-ID: <87v86xeg7q.fsf@nosuchdomain.example.com>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com>
<uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com>
<uq2um0$21dgh$1@dont-email.me> <uq4jm5$2h9hc$2@dont-email.me>
<uq4l7p$2hik2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="639f38d912c33920e0e5a36e0f09675f";
logging-data="2859113"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+T3Gm5iyJW8hR+o0s00X/9"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:BFUdOGTONUzp5u/mtDLrQskFrW0=
sha1:fGS5O0GeTvHQe8hkaOFcFHvx66Q=
 by: Keith Thompson - Fri, 9 Feb 2024 16:48 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
> On 09/02/2024 07:19, David Brown wrote:
>> On 08/02/2024 17:14, Malcolm McLean wrote:
>>> On 08/02/2024 16:04, Keith Thompson wrote:
>>>> In a freestanding implementation, main() *might* be just another
>>>> function.  In that case a compiler can't prove that the code will be
>>>> invoked.
>>>>
>>> Well sometimes it can. The boot routine or program entry point is
>>> by defintion always invoked, and you can generally prove that at
>>> least some code is always reached from that. However it is the
>>> halting problem, and you can never prove for all cases, even if the
>>> code must be reached or not reached regardless of runtime inputs.
>>>
>> It is not "the halting problem".  What you are trying to say, is
>> that it is undecidable or not a computable problem in the general
>> case.
>>
> The "is this code reached?" problem is the halting problem with the
> trivial and unimportant difference that the code in question does not
> have to be "exit()".

Your earlier statement that "it is the halting problem" is at best
questionable, partly because it's not clear what "it" refers to in that
statement.

The issue is not whether we understand what the halting problem is.
The issue is that it's not relevant in this context.

We were discussing whether a compiler can reject a program that has
undefined behavior. It clearly can *if* the undefined behavior will
occur in every execution of the program (for all inputs if the program
has inputs).

If a program includes the expression 1/0, evaluation that expression has
undefined behavior, but there is no undefined behavior if that code is
never reached and the expression is not evaluated.

Determining, for all programs containing the expression 1/0, whether
that expression will be evaluated is (probably) more or less equivalent
to the halting problem, which means that no compiler can perfectly
determine whether it's allowed to reject such programs.

But the halting program is irrelevant because *compilers are not
required to do that*. Most compilers do *some* flow analysis, and can
determine *in some cases* whether a given expression will always,
sometimes, or never be evaluated, but they cannot, do not, and are not
required to do a perfect job. They are not required to do any such
analysis at all. A conforming compiler can issue a non-fatal warning
whenever it sees a division by a constant 0, not caring whether it can
be reached -- or it can ignore the issue altogether (except that it must
detect it if it occurs in a context that requires a constant
expression).

The example was one in which it's trivially provable that the expression
1/0 will be evaluated whenever the program is executed (assuming a
hosted implementation).

And if you and David want to argue about Oxford English degrees, I urge
*both of you* to do it elsewhere. David, you don't have to respond to
everything.

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

Re: ustent on that.

<uq5lnb$2ndrq$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: ustent on that.
Date: Fri, 9 Feb 2024 18:00:26 +0100
Organization: A noiseless patient Spider
Lines: 155
Message-ID: <uq5lnb$2ndrq$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me> <uq4l7p$2hik2$1@dont-email.me>
<uq4o03$2hive$7@dont-email.me> <8734u2q6k6.fsf@bsb.me.uk>
<uq521h$2jk0f$1@dont-email.me> <uq5bbo$2lhsv$1@dont-email.me>
<uq5i8r$2mp0a$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 9 Feb 2024 17:00:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9c8bd9f8f89cf9a03af351ae8d81a71b";
logging-data="2865018"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19leDV3Z3sH8S3ICD5NxZ4/cXKsfwpqSqQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:OJ2Pm0SUq47Y6pEFi48C1dXRfhg=
Content-Language: en-GB
In-Reply-To: <uq5i8r$2mp0a$1@dont-email.me>
 by: David Brown - Fri, 9 Feb 2024 17:00 UTC

On 09/02/2024 17:01, Malcolm McLean wrote:
> On 09/02/2024 14:03, David Brown wrote:
>> On 09/02/2024 12:24, Malcolm McLean wrote:
>>>
>>> And even when I agree there might be some truth in that, and explain
>>> why, I am then accused of misrepresenting what an Oxford English
>>> degree is like.
>>
>> Again, read my posts.  I said your description of your degree does not
>> match my experience with my own degree at Oxford, nor what I heard
>> from others at the time who studied English literature.  You may have
>> given an accurate description of your personal experiences - I have no
>> way to either prove or disprove that, and no reason to suspect you of
>> being intentionally deceptive.  But I believe it to have been unusual,
>> and due to a bad tutor.
>>
>
> OK. So you also attended Oxford. And now I'm surprised.

Why is that surprising?

> That's what
> Oxford English is like. Very much an emphasis on geting things done,
> quickly and to deadlines, because most Oxford English graduates will
> work in careers where that is important. Only a small minority become
> computer programmers like me where a program often has t be perfect ot
> it doesn't work at all. Now whislt of course I don;t have direct
> experience of other colleges, I'm pretty sure my own college was fairly
> normal about this. One tutor was maybe a bit keener than normal.
>  We got essays for next week on an author most of us had never read on
> the very first day, and I dn;t think you;f]=d get that at every college.
> But not far off.
>

Perhaps you should discourage your cat from walking across your keyboard
while trying to type. Surely accurate typing is a skill you need for
programming?

I know literature students (of any language) were expected to work hard,
reading a lot of texts - /all/ students at Oxford had intense workloads.
In computer science, practicals were done in whatever language the
lecturer liked - so you might easily find you have to learn a new
programming language in a couple of weeks, outside of any courses or
tutorials, for answering the practical.

I know literature students were expected to write a lot, quickly - as
were students of most subjects. But IME they were also expected to
write accurately and sensibly. There is no point in doing something
fast, if it is not correct (to the extent that a literature essay can be
"correct").

> I'm really not mischaracterising. Of course you also have to defend the
> essay and it is marked. But that's less important. It's very unusual to
> receive a mark for an essay which is so low that it means that if you
> write a similar essay in finals you will fail. Oxford is extremely
> generous with the lower marks and in ensuring that they are not a fail.

I have seen students at Oxford fail. Not many, but a few.

> Unless of course the candidate submits nothing. In which case it can
> only be a fail. So you must submit something which constitutes an essay
> for the tutorial, and my tutors were very insistent on that.
>

You sound like you were trying to get away the absolute minimum possible
without failing.

> I fell out with my tutor catastrophically over moral issues and because
> of the type of subject English Literature is, that had profound
> implications for my work. He allowed that to happen, he was in the wrong
> about our dispute  and everything I predicted that would happen in
> English Studies has in fact come to pass, and he was therefore a bad
> tutor. But to be fair I was an extremely difficult student.

Such bad chemistry between a student and a tutor happens sometimes,
unfortunately.

But what you are describing is a situation where you scraped through,
learning little from the tutor. That is not normal university experience.

>
>>> If you change the halting problem such that some of the symbols on
>>> the tape are allowed to have unknown values then I don't think you
>>> are changing it in any mathematically very interesting way so it is
>>> still "trival", but if you attempt a halt decider it will
>>> substantially change your programming approach, and so it is no
>>> longer "unimportant".
>>>
>>
>> I would prefer to think a bit about how a volatile input tape would
>> relate to the halting problem as it is normally stated, before
>> offering an opinion on how it may or may not change the result.  I
>> suspect you are correct that it will not change the problem or the
>> results, but I would want to be a bit more rigorous about what is
>> meant before jumping to conclusions.
>>
> Well this is it isn't it. Employ a computer scientist as a mathematician
> and you'll get a rigorous proof. Employ an English graduate (and I have
> actually held the job title "mathematician" though I am in no way
> qualified to describe myself as such) and he quickly guesses. But are
> you so surprised that you think I am thereby misrepresenting Oxford
> English? And the English graduate does at least produce something
> constructive quickly.
>

I think your situation at university was unusual, as you describe it -
though not impossible.

And I would expect someone who has a degree in English to be more
accurate in the language they write. Perhaps my expectations are
unreasonable, but in comparison to other regulars here, your rate of
typos, spelling mistakes, grammatical errors, and - more importantly -
confusing and unclear wording, is significantly higher. We all make
mistakes at times, but to reach your level shows a lack of care and a
lack of attention to detail. It is not a matter of producing things
quickly - it is laziness.

Put it this way. If you were to apply to my department for a job as a
programmer, and you wrote your CV and cover letter in the style you
write in this newsgroup, I would reject you on that basis alone.

> >
>> However, I have no idea what you mean by "if you attempt a halt
>> decider it will substantially change your programming approach".
>>
> We're changing the model slightly so that instead of all the input tape
> being available to the decider, some values are unknown. It still has to
> determine whether the program will halt or not, and whilst sometimes
> this will now be inherently impossible because the answer depends on the
> input, often it will not be so. As I said, I don't think anything much
> has actually changed. But it does mean that we now have to write our
> halt decider in a different way. It's no longer as simple as replacing
> the code we want to know is reached by exit() and declaring that it is
> now the halting problem.
>
> The halt decider will fail to work as specified on some inputs, so I say
> "attempt a halt decider". You can have a go. But it won't actually work.
>

So when you write "if you attempt a halt decider", you mean something
like attempting to "write" a halt decider, or "design", or "test", or
"run" a halt decider? And doing this will somehow "change your
programming approach" ? Are you trying to say that if you allow some
input values to be unknown, it changes how you design your halt decider?
That would make no sense, because you /can't/ design a general halt
decider (without transfinite computation models and "oracles"). Are you
trying to say that if someone spends time trying to do this, it will
change their attitude to programming in general?

Your first attempt at explaining this made no sense. Your second
attempt did not help at all. Perhaps it is best just to leave it alone.

Re: Is C ready to become a safer language?

<uq5tl5$2ooie$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.samoylyk.net!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 9 Feb 2024 20:15:49 +0100
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <uq5tl5$2ooie$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq4jca$2h9hc$1@dont-email.me>
<8734u1fvqf.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 9 Feb 2024 19:15:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2ac7bc3d44bf8717c1088c337fb68b71";
logging-data="2908750"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX186dw4eKPUpQ/xeP482btP7XLeh/FTmHKs="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:U11Njj2PYq6XZDly0CJupJ4Tg0E=
In-Reply-To: <8734u1fvqf.fsf@nosuchdomain.example.com>
Content-Language: en-GB
 by: David Brown - Fri, 9 Feb 2024 19:15 UTC

On 09/02/2024 17:28, Keith Thompson wrote:
> David Brown <david.brown@hesbynett.no> writes:
> [...]
>> But I am not sure that the /compiler/ knows that it is compiling for a
>> hosted or freestanding implementation. The same gcc can be used for
>> Linux hosted user code and a freestanding Linux kernel.
> [...]
>
> A conforming compiler must predefine the macro __STDC_HOSTED__ to either
> 0 or 1 (since C99).
>

Okay, that looks like a difference. A compiler could, I believe, call
itself "freestanding", define that to 0, and otherwise act exactly like
a hosted implementation. But it seems unlikely.

Re: ustent on that.

<uq6j05$2sads$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.samoylyk.net!nyheter.lysator.liu.se!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: malcolm....@gmail.com (Malcolm McLean)
Newsgroups: comp.lang.c
Subject: Re: ustent on that.
Date: Sat, 10 Feb 2024 01:20:04 +0000
Organization: A noiseless patient Spider
Lines: 117
Message-ID: <uq6j05$2sads$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me>
<87jznfh7p6.fsf@nosuchdomain.example.com> <uq22na$1sppb$1@dont-email.me>
<87bk8rgcy0.fsf@nosuchdomain.example.com> <uq2um0$21dgh$1@dont-email.me>
<uq4jm5$2h9hc$2@dont-email.me> <uq4l7p$2hik2$1@dont-email.me>
<uq4o03$2hive$7@dont-email.me> <8734u2q6k6.fsf@bsb.me.uk>
<uq521h$2jk0f$1@dont-email.me> <uq5bbo$2lhsv$1@dont-email.me>
<uq5i8r$2mp0a$1@dont-email.me> <uq5lnb$2ndrq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 10 Feb 2024 01:20:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f1ffd46acf87320bfb11b15ae24bdde1";
logging-data="3025340"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+12+VXrxmMw8KbLXvVhKZ3/+fMkpviwrw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:g0CWGHkpjEC10Ntpy/bdv2rgrjM=
Content-Language: en-GB
In-Reply-To: <uq5lnb$2ndrq$1@dont-email.me>
 by: Malcolm McLean - Sat, 10 Feb 2024 01:20 UTC

On 09/02/2024 17:00, David Brown wrote:
> On 09/02/2024 17:01, Malcolm McLean wrote:
>
>> OK. So you also attended Oxford. And now I'm surprised.
>
> Why is that surprising?
>
You don't seem to have the same understanding as me about what makes
Oxford tick,

> There is no point in doing something
> fast, if it is not correct (to the extent that a literature essay can be
> "correct").
>
>> I'm really not mischaracterising. Of course you also have to defend
>> the essay and it is marked. But that's less important. It's very
>> unusual to receive a mark for an essay which is so low that it means
>> that if you write a similar essay in finals you will fail. Oxford is
>> extremely generous with the lower marks and in ensuring that they are
>> not a fail.
>
> I have seen students at Oxford fail.  Not many, but a few.
>
There is a point in dong something fast but not correct, and I think I
explained it very clearly. Something fast but not correct may get a low
mark, but as long as it is not too badly incorrect, it will pass.
Something slow and accurate but not submitted on time will receive a
fail. Now maybe less so in computer science.

>> Unless of course the candidate submits nothing. In which case it can
>> only be a fail. So you must submit something which constitutes an
>> essay for the tutorial, and my tutors were very insistent on that.
>>
>
> You sound like you were trying to get away the absolute minimum possible
> without failing.
>
My experience is that people at Oxford just don't think lke that.
Obviously your exoerience must have been different. That's what I mean
about being surprised.

>
> Such bad chemistry between a student and a tutor happens sometimes,
> unfortunately.
>
> But what you are describing is a situation where you scraped through,
> learning little from the tutor.  That is not normal university experience.
>
I wasn't really bad chemistry. I disgreed with him over some moral
issues, and ultimately the direction in which he was taking the other
students, and we fell out. It's not normal to have such a dispute, I
agree. However whilst he was my personal tutor, he wasn't my only tutor,
and I remained on good terms with the others. In some ways I was a very
difficult student.

> I think your situation at university was unusual, as you describe it -
> though not impossible.
>
Surely you are not saying that this is all invented? It did actually
happen, and so, no, it can't have been impossible.

> And I would expect someone who has a degree in English to be more
> accurate in the language they write.  Perhaps my expectations are
> unreasonable, but in comparison to other regulars here, your rate of
> typos, spelling mistakes, grammatical errors, and - more importantly -
> confusing and unclear wording, is significantly higher.  We all make
> mistakes at times, but to reach your level shows a lack of care and a
> lack of attention to detail.  It is not a matter of producing things
> quickly - it is laziness.
>
> Put it this way.  If you were to apply to my department for a job as a
> programmer, and you wrote your CV and cover letter in the style you
> write in this newsgroup, I would reject you on that basis alone.
>
Whilst I'd have no hesitation at all in recommedending you for a job as
a programmer with us.
>
>>  >
>>> However, I have no idea what you mean by "if you attempt a halt
>>> decider it will substantially change your programming approach".
>>>
>> We're changing the model slightly so that instead of all the input
>> tape being available to the decider, some values are unknown. It still
>> has to determine whether the program will halt or not, and whilst
>> sometimes this will now be inherently impossible because the answer
>> depends on the input, often it will not be so. As I said, I don't
>> think anything much has actually changed. But it does mean that we now
>> have to write our halt decider in a different way. It's no longer as
>> simple as replacing the code we want to know is reached by exit() and
>> declaring that it is now the halting problem.
>>
>> The halt decider will fail to work as specified on some inputs, so I
>> say "attempt a halt decider". You can have a go. But it won't actually
>> work.
>>
>
> So when you write "if you attempt a halt decider", you mean something
> like attempting to "write" a halt decider, or "design", or "test", or
> "run" a halt decider?  And doing this will somehow "change your
> programming approach" ?  Are you trying to say that if you allow some
> input values to be unknown, it changes how you design your halt decider?
>  That would make no sense, because you /can't/ design a general halt
> decider (without transfinite computation models and "oracles").  Are you
> trying to say that if someone spends time trying to do this, it will
> change their attitude to programming in general?
>
> Your first attempt at explaining this made no sense.  Your second
> attempt did not help at all.  Perhaps it is best just to leave it alone.
>
>
Now am I unclear or are you obtuse? Are people so contentious that they
can't understand, or is it genuinely my fault?

--
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm

Re: Is C ready to become a safer language?

<86eddl5bag.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Fri, 09 Feb 2024 17:59:51 -0800
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <86eddl5bag.fsf@linuxsc.com>
References: <uq1jnk$1qebo$2@dont-email.me> <uq2vjp$21qev$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="c20874413056af7bcbd7e84e1693869d";
logging-data="3034887"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UXxiFJmeFtjBVoGhM9iSiQe9p8NccN9Q="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:jVSp1tI705mTS9l8ZxUbXNLzH04=
sha1:31Su/JPw1pBiYm4jjVwYztDHAa8=
 by: Tim Rentsch - Sat, 10 Feb 2024 01:59 UTC

bart <bc@freeuk.com> writes:

[...]

> This is something which has long been of fascination to me: how
> exactly do you get a C compiler to actually fail a program with a
> hard error when there is obviously something wrong, while not also
> failing on completely harmless matters.

I think the answer is obvious: unless and until you find someone
who works on a C compiler and who has exactly the same sense that
you do of "when there is obviously something wrong" and of what
conditions fall under the heading of "completely harmless matters",
and also the same sense that you do of how a C compiler should
behave in those cases, you won't get exactly what you want unless
you do it yourself.

Re: Is C ready to become a safer language?

<865xyw62av.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Sat, 10 Feb 2024 02:28:40 -0800
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <865xyw62av.fsf@linuxsc.com>
References: <uq1jnk$1qebo$2@dont-email.me> <87jznfh7p6.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="c20874413056af7bcbd7e84e1693869d";
logging-data="3296918"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18J+D0oMLrlI7rPQvbvdm2/KTKcOLNmHGw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:MO1hs1+jsPwZjSKxCweN0AQe1JY=
sha1:PDidF3Y6nyq41gC/tfPjqRntEWA=
 by: Tim Rentsch - Sat, 10 Feb 2024 10:28 UTC

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

> Thiago Adams <thiago.adams@gmail.com> writes:
>
>> Let's say C compilers can detect all sorts of bugs at compile time.
>>
>> How would C compilers report that? As an error or a warning?
>>
>> Let's use this sample:
>>
>> int main() {
>> int a = 1;
>> a = a / 0;
>> }
>>
>> GCC says:
>>
>> warning: division by zero is undefined [-Wdivision-by-zero]
>> 5 | a = a / 0;
>> | ^ ~
>>
>> In case GCC or any other compiler reports this as an error, then C
>> programmers would likely complain. Am I right?
>
> Someone will always complain, but a conforming compiler can report this
> as a fatal error.
>
> Division by zero has undefine behavior. Under the standard's definition
> of undefined behavior, it says:
>
> NOTE
>
> Possible undefined behavior ranges from ignoring the situation
> completely with unpredictable results, to behaving during
> translation or program execution in a documented manner
> characteristic of the environment (with or without the issuance
> of a diagnostic message), to terminating a translation or
> execution (with the issuance of a diagnostic message).
>
> Though it's not quite that simple. Rejecting the program if the
> compiler can't prove that the division will be executed would IMHO
> be non-conforming. Code that's never executed has no behavior, so
> it doesn't have undefined behavior.

An implementation can refuse to translate the program, but not
because undefined behavior occurs. The undefined behavior here
happens only when the program is executed, but just compiling the
program doesn't do that. No execution, no undefined behavior.
Still the program may be rejected, because it is not strictly
conforming (by virtue of having output depend on the undefined
behavior if the program is ever run).

Re: Is C ready to become a safer language?

<uq8lus$3dceu$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Sat, 10 Feb 2024 20:22:52 +0000
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <uq8lus$3dceu$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me> <uq2vjp$21qev$1@dont-email.me>
<86eddl5bag.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 10 Feb 2024 20:22:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="174e203a272e08607ec691b159e8c7c3";
logging-data="3584478"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19841eTMPFTH+En5C38pamCDjeeY6GaIGc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Rw1zRJXcEgOetIUBtCFW+3HkyYk=
In-Reply-To: <86eddl5bag.fsf@linuxsc.com>
Content-Language: en-GB
 by: bart - Sat, 10 Feb 2024 20:22 UTC

On 10/02/2024 01:59, Tim Rentsch wrote:
> bart <bc@freeuk.com> writes:
>
> [...]
>
>> This is something which has long been of fascination to me: how
>> exactly do you get a C compiler to actually fail a program with a
>> hard error when there is obviously something wrong, while not also
>> failing on completely harmless matters.
>
> I think the answer is obvious: unless and until you find someone
> who works on a C compiler and who has exactly the same sense that
> you do of "when there is obviously something wrong" and of what
> conditions fall under the heading of "completely harmless matters",
> and also the same sense that you do of how a C compiler should
> behave in those cases, you won't get exactly what you want unless
> you do it yourself.

Take this function:

void F() {
F();
F(1);
F(1, 2.0);
F(1, 2.0, "3");
F(1, 2.0, "3", F);
}

Even if /one/ of those calls is correct, the other four can't be
possibly be correct as well.

Is there anyone here who doesn't think there is something obviously wrong?

How about this one:

#include <stdio.h>
int main(void) {
int a;
L1:
printf("Hello, World!\n");
}

Ramp up the warnings and a compiler will tell you about unused 'a' and
'L1'. Use -Werror and the compilation will fail.

Is there anyone here who thinks that running this program with those
unused identifiers is not completely harmless?

Re: Is C ready to become a safer language?

<uq8psv$1vfl$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: richard....@gmail.invalid (Richard Harnden)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Sat, 10 Feb 2024 21:30:07 +0000
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <uq8psv$1vfl$1@dont-email.me>
References: <uq1jnk$1qebo$2@dont-email.me> <uq2vjp$21qev$1@dont-email.me>
<86eddl5bag.fsf@linuxsc.com> <uq8lus$3dceu$1@dont-email.me>
Reply-To: nospam.harnden@invalid.com
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 10 Feb 2024 21:30:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ea25f560cbe16ee66b2e83e3825ee66c";
logging-data="65013"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ER2tt9M5IYIdcztZ9AxOa6t0g+xeBoDA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:mPGxjnLwTxW8wm97qcw74/+Q3lA=
Content-Language: en-GB
In-Reply-To: <uq8lus$3dceu$1@dont-email.me>
 by: Richard Harnden - Sat, 10 Feb 2024 21:30 UTC

On 10/02/2024 20:22, bart wrote:
> On 10/02/2024 01:59, Tim Rentsch wrote:
>> bart <bc@freeuk.com> writes:
>>
>> [...]
>>
>>> This is something which has long been of fascination to me:  how
>>> exactly do you get a C compiler to actually fail a program with a
>>> hard error when there is obviously something wrong, while not also
>>> failing on completely harmless matters.
>>
>> I think the answer is obvious:  unless and until you find someone
>> who works on a C compiler and who has exactly the same sense that
>> you do of "when there is obviously something wrong" and of what
>> conditions fall under the heading of "completely harmless matters",
>> and also the same sense that you do of how a C compiler should
>> behave in those cases, you won't get exactly what you want unless
>> you do it yourself.
>
>
> Take this function:
>
>   void F() {
>     F();
>     F(1);
>     F(1, 2.0);
>     F(1, 2.0, "3");
>     F(1, 2.0, "3", F);
>   }
>
> Even if /one/ of those calls is correct, the other four can't be
> possibly be correct as well.
>
> Is there anyone here who doesn't think there is something obviously wrong?

Gcc says, "warning: passing arguments to 'F' without a prototype is
deprecated in all versions of C and is not supported in C2x
[-Wdeprecated-non-prototype]"
>
> How about this one:
>
>   #include <stdio.h>
>   int main(void) {
>     int a;
>     L1:
>     printf("Hello, World!\n");
>   }
>
> Ramp up the warnings and a compiler will tell you about unused 'a' and
> 'L1'. Use -Werror and the compilation will fail.
>
> Is there anyone here who thinks that running this program with those
> unused identifiers is not completely harmless?

The point of the warning is that maybe you meant to use them. Remove
them if they're not needed, or fix the code so they do get used.

Re: Is C ready to become a safer language?

<20240210132352.798@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Is C ready to become a safer language?
Date: Sat, 10 Feb 2024 21:49:20 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <20240210132352.798@kylheku.com>
References: <uq1jnk$1qebo$2@dont-email.me> <uq2vjp$21qev$1@dont-email.me>
<86eddl5bag.fsf@linuxsc.com> <uq8lus$3dceu$1@dont-email.me>
Injection-Date: Sat, 10 Feb 2024 21:49:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3de03a7474c831a6f9d55487e9415a62";
logging-data="72715"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4HG2EBb4Efh5y0LVzVQL51VtvyYqIuqg="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:FPB/R/OqyDbtk7sbfpYPx269+Wc=
 by: Kaz Kylheku - Sat, 10 Feb 2024 21:49 UTC

On 2024-02-10, bart <bc@freeuk.com> wrote:
> #include <stdio.h>
> int main(void) {
> int a;
> L1:
> printf("Hello, World!\n");
> }
>
> Ramp up the warnings and a compiler will tell you about unused 'a' and
> 'L1'. Use -Werror and the compilation will fail.
>
> Is there anyone here who thinks that running this program with those
> unused identifiers is not completely harmless?

Unused warnings exist because they help catch bugs.

double distance(double x, double y)
{
return sqrt(x*x + x*x);
}

The diagnostic will not catch all bugs of this type, since just one use is
enough to silence it, but catching something is better than nothing.

Removing unused cruft also helps to keep the code clean. Stray material
sometimes gets left behind after refactoring, or careless copy paste.
Unused identifiers are a "code smell".

Sometimes something must be left unused. It's good to be explicit about
that: to have some indication that it's deliberately unused.

When I implemented unused warnings in my Lisp compiler, I found a bug right away.

https://www.kylheku.com/cgit/txr/commit/?id=5ee2cd3b2304287c010237e03be4d181412e066f

In this diff hunk against in the assembler:

@@ -217,9 +218,9 @@
(q me.(cur-pos)))
(inc c)
me.(set-pos p)
- (format t "~,5d: ~,08X ~a\n" (trunc p 4) me.(get-word) dis-txt)
+ (format stream "~,5d: ~,08X ~a\n" (trunc p 4) me.(get-word) dis-txt)
(while (< (inc p 4) q)
- (format t "~,5d: ~,08X\n" (trunc p 4) me.(get-word)))
+ (format stream "~,5d: ~,08X\n" (trunc p 4) me.(get-word)))
me.(set-pos q)
(set p q)))
c))

The format function was given argument t, a nickname for standard output, so
this code ignored the stream parameter and always sent output to standard
output.

With the unused warnings, it got diagnosed.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca


devel / comp.lang.c / Re: Is C ready to become a safer language?

Pages:1234
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor