The intention could be to force the program to execute its exception handler
*(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
171–180 of 199 posts
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#172dereferencing null is a great debug technique
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#173Afaik, that's a "portable" way to trigger a termination with dump collection :) (particularly on Windows if you just std::terminate you won't get a heap dump unless you do special WER registration and register handlers).
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#174Afaik, that's a "portable" way to trigger a termination with dump collection :) (particularly on Windows if you just std::terminate you won't get a heap dump unless you do special WER registration and register handlers).
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#175Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#176For the typical non-coder hacker news reader: Wait for C++ coder to get disney sponsorship for a stack frame version of/translation to George Lucas expressions / Steven Speilburg expressions. aka * wars vs. * trek crossover comparisons, perhaps with less () than lisp/scheme take. Ideally, in UTF format so no "7 samuri/8 bit kleen", AND/OR, lower API, protocol droids distractions. In interm, learn python, show a pytho…
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#177When I see that code my head immediately translates to "store a byte with value 0 at memory address zero". 0 the integer needs to be cast to a char * to treat it as a byte address (rather than a word) and the * means "assign to the memory location given by the pointer. I would probably use something like this when hacking on an Apple II with a zero page. I have also written programs that ran on VMS which dumped memor…
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…
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#178For the typical non-coder hacker news reader: Wait for C++ coder to get disney sponsorship for a stack frame version of/translation to George Lucas expressions / Steven Speilburg expressions. aka * wars vs. * trek crossover comparisons, perhaps with less () than lisp/scheme take. Ideally, in UTF format so no "7 samuri/8 bit kleen", AND/OR, lower API, protocol droids distractions. In interm, learn python, show a pytho…
"Eigen Maze by this pointer" may be theme song for this post; but no letting things be in order to let this stack down to get this pointer back to complete 'init & kill -9' autonoma sequence.
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#179Kind of a tangent, but I've never seen that signature for main with char *apple at the end after char *envp. What's passed in there? Some googling let me know it's used on macOS, but every result was too generic to be helpful.