Isn’t the size of a function’s address known at compilation type ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Arithmetic operations on a pointer treats the pointer as an array of objects of a given type. So when you add 3 to an
int *, you advance by threeints.Function pointers cannot be interpreted as arrays of anything. Instructions, maybe, or maybe not. Some machines have separate a address space for instructions. Some machines have variable-length instructions.
As an aside, the size of the function is known at compile time, but only after the compiler has finished its work. Compiling the size of a function into itself can be tricky in assembly language, the only sort of programming with any hope of forming such a construct.