Sujet : Re: Formal systems that cannot possibly be incomplete except for unknowns and unknowable
De : rjh (at) *nospam* cpax.org.uk (Richard Heathfield)
Groupes : comp.theoryDate : 08. May 2025, 05:09:07
Autres entêtes
Organisation : Fix this later
Message-ID : <vvhap5$1hp80$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
User-Agent : Mozilla Thunderbird
On 08/05/2025 02:20, olcott wrote:
<snip>
Does there exist an HHH such that DDD emulated by
HHH according to the rules of the C programming language
Let's take a look.
The file is 1373 lines long, but don't worry, because I plan to stop at HHH's first departure from the rules of the C programming language (or at least the first departure I spot).
Turn in your songbook if you will to:
void CopyMachineCode(u8* source, u8** destination)
{
u32 size;
for (size = 0; source[size] != 0xcc; size++)
;
*destination = (u8*) Allocate(size);
for (u32 N = 0; N < size; N++)
{
Output("source[N]: ", source[N]);
*destination[N] = source[N];
}
((u32*)*destination)[-1] = size;
Output("CopyMachineCode destination[-1]: ", ((u32*)*destination)[-1]);
Output("CopyMachineCode destination[-2]: ", ((u32*)*destination)[-2]);
};
I'll ignore the syntax error (a null statement at file scope is a rookie error).
Instead, let's jump straight to this line:
*destination = (u8*) Allocate(size);
On line 79 of my copy of the code, we find:
u32* Allocate(u32 size) { return 0; }
In C, 0 is a null pointer constant, so Allocate returns a null pointer constant... which is fine as long as you don't try to deref it. So now *destination is NULL.
We go on:
for (u32 N = 0; N < size; N++)
{
Output("source[N]: ", source[N]);
*destination[N] = source[N];
}
*destination[N] is our first big problem (we're ignoring syntax errors, remember). destination is a null pointer, so destination[N] derefs a null pointer.
That's a fail. 0/10, D-, go away and write it again. And you /dare/ to impugn other people's C knowledge! Crack a book, for pity's sake.
-- Richard HeathfieldEmail: rjh at cpax dot org dot uk"Usenet is a strange place" - dmr 29 July 1999Sig line 4 vacant - apply within