From patchwork Tue Oct 6 11:57:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 8939 Received: (qmail 105956 invoked by alias); 6 Oct 2015 11:57:48 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 105946 invoked by uid 89); 6 Oct 2015 11:57:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com To: GNU C Library From: Florian Weimer Subject: [PATCH] The va_list pointer is unspecified after a call to vfprintf [BZ #18982] Message-ID: <5613B736.4000504@redhat.com> Date: Tue, 6 Oct 2015 13:57:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 This adjusts the documentation to the existing implementation. Florian 2015-10-06 Florian Weimer [BZ #18982] * manual/stdio.texi (Variable Arguments Output): Add portability note, explaining that vfprintf clobbers the va_list pointer. diff --git a/NEWS b/NEWS index 0f3f33f..b7bc458 100644 --- a/NEWS +++ b/NEWS @@ -17,8 +17,8 @@ Version 2.23 18757, 18778, 18781, 18787, 18789, 18790, 18795, 18796, 18803, 18820, 18823, 18824, 18825, 18857, 18863, 18870, 18872, 18873, 18875, 18887, 18921, 18951, 18952, 18956, 18961, 18966, 18967, 18969, 18970, 18977, - 18980, 18981, 18985, 19003, 19012, 19016, 19018, 19032, 19046, 19049, - 19050, 19059, 19071. + 18980, 18981, 18982, 18985, 19003, 19012, 19016, 19018, 19032, 19046, + 19049, 19050, 19059, 19071. * The obsolete header has been removed. Programs that require this header must be updated to use instead. 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