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).
I think the problem is in you sending a
doubleas3instead of3.0. A normal3will be treated as integer but in thetestfunction you are retrieving doubles which are bigger than aninton most platforms and you might end up reading wrong locations which inturn leads toEXC_BAD_ACCESSrun time signal being generated