Earlier quoted context omitted.
> sizeof(char) (== 1 almost everywhere) sizeof char is 1 by definition everywhere. /pedantic
In the mathematical sense of almost, a property that holds everywhere does qualify as holding almost everywhere.
*(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
191–199 of 199 posts
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#192Earlier quoted context omitted.
> sizeof(char) (== 1 almost everywhere) sizeof char is 1 by definition everywhere. /pedantic
In the mathematical sense of almost, a property that holds everywhere does qualify as holding almost everywhere.
-----
unless initial property is start of dynamic operation, in which case, holding almost anywhere begins at the first operation after the start of the dynamic operation. process / lambda / epsilon calculi is just symbolic math. address 0 static, everything else dynamic.
per math, dimension N is static, to be able to "change things up" in dimension N, need to to be almost everywhere higher than dimension n. Edge cases are weird in any dimension. Guess why logicians just do the equivalent of C's !0
(cast classic logic) A=1 (cast boolean logic) B=0
C statement !(!B == A) hold everywhere and almost everywhere depends on how read C spec to interpret A & B.
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#193Ideally after the appropriate cast of characters has had a no-fault OS page(s) performance.
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#194Earlier quoted context omitted.
This is C code. Coder needs specifity hwo to align the char pointer to HW alignment expectations for memory address to prevent a segmentation fault.
Char pointers have alignment 1 on any conforming implementation and all pointers are aligned at 0. The code will write to "address 0", assuming the compiler hasn't freaked out because (char*)0 is the char null pointer and thus undefined behavior to access. Note the additional caveat that address 0 may not be the first 8 bits of mapped memory (which isn't necessarily addressable).
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#195Earlier quoted context omitted.
This is C code. Coder needs specifity hwo to align the char pointer to HW alignment expectations for memory address to prevent a segmentation fault.
Char pointers have alignment 1 on any conforming implementation and all pointers are aligned at 0. The code will write to "address 0", assuming the compiler hasn't freaked out because (char*)0 is the char null pointer and thus undefined behavior to access. Note the additional caveat that address 0 may not be the first 8 bits of mapped memory (which isn't necessarily addressable).
The code can do something shifty at run time, without a power surge, to the address reference before the address is de-referenced
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#196The intention could be to force the program to execute its exception handler
Pointers and type safety still causing issues decades later.
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#197Earlier quoted context omitted.
No, it’s not a guarantee, it’s just a noisy filter with a very high false negative rate and a high enough false positive rate (as visible in malpractice insurance).
I certainly is, those numbers would be much higher without that filter.
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#198Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#199Earlier quoted context omitted.
You're mostly correct but to be pedantic, in C the literal value 0 does not actually mean address 0. The literal value of 0 is an implementation defined value that represents a null pointer, but that value does not have to be address 0, it could be some other address. This is significant because the following two snippets of code are not required to be equal in C. char* c = (char*)(0); char* d; memset(&d, 0, sizeof(d…
> that value does not have to be address 0, it could be some other address. That's what the spec says, but are there any computers around anymore where nullptr is not zero? The spec should really go with the times IMHO, old hardware can be supported via platform-specific language extensions.