[PATCH] missing va_end() in some IO functions (gmp 6.1.2)

Vincent Lefevre vincent at vinc17.net
Thu Mar 14 12:29:10 UTC 2019

On 2019-03-14 12:38:13 +0100, Torbjorn Granlund wrote:
> My bad, part of Jakub's patch is needed for standards compliance.
> In gmp-impl.h, we have this:
>   /* va_copy is standard in C99, and gcc provides __va_copy when in strict C89
>      mode.  Falling back to a memcpy will give maximum portability, since it
>      works no matter whether va_list is a pointer, struct or array.  */
>   #if ! defined (va_copy) && defined (__va_copy)
>   #define va_copy(dst,src)  __va_copy(dst,src)
>   #endif
>   #if ! defined (va_copy)
>   #define va_copy(dst,src) \
>     do { memcpy (&(dst), &(src), sizeof (va_list)); } while (0)
>   #endif
> We still support ISO C90 (alias ANSI C89) so we cannot just scrap that
> code.  That means that we mustn't call va_end when memcpy was used by
> means of the code above.

But will va_arg necessarily work when va_copy is just a memcpy
(at least in the case where va_end is *not* empty)? This seems

Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

More information about the gmp-bugs mailing list