From f546f87c4ffb1642ffc96b8d614c329ed35252c3 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Sat, 17 Oct 2015 12:02:22 +0200 Subject: The va_list pointer is unspecified after a call to vfprintf [BZ #18982] This adjusts the documentation to the existing implementation. --- manual/stdio.texi | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'manual') diff --git a/manual/stdio.texi b/manual/stdio.texi index 5d31774..c0753b1 100644 --- a/manual/stdio.texi +++ b/manual/stdio.texi @@ -2621,20 +2621,16 @@ choice, you are ready to call @code{vprintf}. That argument and all subsequent arguments that were passed to your function are used by @code{vprintf} along with the template that you specified separately. -In some other systems, the @code{va_list} pointer may become invalid -after the call to @code{vprintf}, so you must not use @code{va_arg} -after you call @code{vprintf}. Instead, you should call @code{va_end} -to retire the pointer from service. However, you can safely call -@code{va_start} on another pointer variable and begin fetching the -arguments again through that pointer. Calling @code{vprintf} does not -destroy the argument list of your function, merely the particular -pointer that you passed to it. - -GNU C does not have such restrictions. You can safely continue to fetch -arguments from a @code{va_list} pointer after passing it to -@code{vprintf}, and @code{va_end} is a no-op. (Note, however, that -subsequent @code{va_arg} calls will fetch the same arguments which -@code{vprintf} previously used.) +@strong{Portability Note:} The value of the @code{va_list} pointer is +undetermined after the call to @code{vprintf}, so you must not use +@code{va_arg} after you call @code{vprintf}. Instead, you should call +@code{va_end} to retire the pointer from service. You can call +@code{va_start} again and begin fetching the arguments from the start of +the variable argument list. (Alternatively, you can use @code{va_copy} +to make a copy of the @code{va_list} pointer before calling +@code{vfprintf}.) Calling @code{vprintf} does not destroy the argument +list of your function, merely the particular pointer that you passed to +it. Prototypes for these functions are declared in @file{stdio.h}. @pindex stdio.h -- cgit v1.1