mahesha wrote:
What should be the behaviour of following program?. Is this behaviour
is undefined or compiler should report error for this case?. Can
anybody point me to pages in the standard where it is explained.
#include <stdarg.h>
void goo(int a) {
va_list args;
va_start(args, a);
}
int main() {
goo(2);
}
In the C Standard (and also reiterated in the C++ Standard), it says
that *unless* the second argument to 'va_start' is the last named
argument before the "..." (", ..." in C), the behaviour is undefined.
Essentially we can conclude that the use of that macro in a function
that does not contain the ellipsis results in undefined behaviour,
since (like the 'a' in your example above) the argument would not be
"the last *before*" the ellipsis. That's the safest assumption I can
figure out.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask