This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems with var_args - TAKE CARE!

You all know the scenario. Just before release, we go round and remove debug stuff. But due to data-overlaying and other stuff, we might not want to change our calling tree and instead choose to remove "the guts" of our debug functions. That should be a pretty safe thing to do.

TAKE CARE! When, at the last minute before release, I removed the the body (including calls to va_list va_start() and va_end()) from a function that took variable arguments, all hell broke loose and the next six hours (spanning midnight) were spent trying to find out why my code was executing from unpopulated address space.

It would seem that the var_args support makes some assumptions about va_end() being called even if va_start isn't.
I never got to the bottom of it (something to do with interactions with the stack when calling between banks), but by sharing my experiences, perhaps others won't have to go through what I had to.

TAKE CARE WITH VAR_ARGS - they may not work as you expect in all situations.

0