1

I get an EXC_BAD_ACCESS error in the last statement when calling the following simplified function:

void test(char *param, ...) {
  va_list vl;
  va_start(vl, param);
  double a = va_arg(vl, double);
  double b = va_arg(vl, double);
  double *result = va_arg(vl, double*);
  *result = a*b;
  va_end(vl);
}

The function is called with:

double result;
test("blub", 3, 3, &result);

I'm using Xcode's clang compiler (Apple LLVM compiler 3.1).

1 Answer 1

4

I think the problem is in you sending a double as 3 instead of 3.0. A normal 3 will be treated as integer but in the test function you are retrieving doubles which are bigger than an int on most platforms and you might end up reading wrong locations which inturn leads to EXC_BAD_ACCESS run time signal being generated

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.