I have function taking a variable and NULL terminated list of pointer arguments using the elipsis. I know about variable length template argument lists. It is about legacy code. Will the following two calls lead to undefined behaviour because the terminator is interpreted as Serializable* by va_arg? What are the differences between the two calls?
void serialize(Serializable* first, ...) {
va_list vl;
va_start(vl, first);
while(1)
{
Serializable* arg = va_arg(vl, Serializable*);
if(arg == NULL)
break;
/* serialize arg here */
}
}
serialize(obj1, obj2, obj3, NULL);
serialize(obj1, obj2, obj3, nullptr);