Is len correctly initialized and safe in set_array call?
void object_copy (Object* self, Object* obj) {
int len;
object_set_array (self, object_get_array (obj, &len), len);
}
If not, what would you recommend?
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.
No – there’s no defined order of evaluation for arguments to a function call.
Even though the call to
object_get_array()has to occur before the call toobject_set_array(), the value that the compiler calculates and passes toobject_set_array()for thelenparameter can be done before the compiler makes the call toobject_get_array().I’m not sure what the 2nd parameter to the
object_set_array()call is intended to be – maybe you wanted to use the comma operator:Which would work, but is confusing and something I wouldn’t recommend.
I think what you want is: