Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Bikonja23838y@Forside a void function does not have a return value, whereas a null pointer is used when there's a possibility of a value, but you don't have a value at that time.
-
Forside14598y@Bikonja Not entirely true. Although they are not supposed to have a return value, internally a return value is nothing but what's stored at EAX. In C you can cast a void function to another deceleration so it becomes something returning an int for example. The return value will be, what's last stored to EAX inside the function.
-
Bikonja23838y@Forside that's a good point, but still, void is not a thing in assembler and registers are not a thing in C (afaik) so within the context of C, where void exists, there's still the difference, even though at assembler level you can get around that and nullify (no pun intended :)) the difference between the two
-
Forside14598y@Bikonja Also a good point. void is nothing but an instruction for the compiler, so it knows it should not look for a return value. I like C so much because of its low level capabilities like accessing and manipulating registers. We once had a task in class where the program should skip a line after a function call by manipulating the return address of the called function. Was supposed to be done by using the address of a variable inside the function to find the address of the return address. I thought fuck it and used an asm command to directly override the return address by using the esp (or ebp? Not sure anymore) register. Was fun.
-
Koolstr27858y@Forside I like the intelligent discussion I've catalyzed. Oddly, I just took my operating systems class final a few days ago, and the first question on it was exactly on what you did. To take advantage of the buffer overflow exploit, you overwrite the esp register, that is correct. It's changing what's on the stack pointer, hence a stack overflow.
Related Rants
I've just noticed, the rest of the world says things like "your check is null and void," as if those two things are one and the same.
Meanwhile, to us devs, they couldn't be any more different! Something can't be both null AND void! 😅
undefined
void
null
function return values
memory locations
c
declaring variables
c++
coding
pointers