Ciao, gcc complains about missing call to 'va_end' in scanf/doscan.c and printf/doprnt.c .
man stdarg on my Debian reads: "Each invocation of va_copy() must be matched by a corresponding invocation of va_end() in the same function." So that probably gcc is right. I assume we never noticed, because probably va_end is a noop, But, we may want to correct it anyway. Correcting scanf/doscan.c is quite easy, I'd suggest: ~/src/gmp$ hg diff scanf/doscan.c diff -r 8225bdfc499f scanf/doscan.c --- a/scanf/doscan.c Tue Sep 05 18:32:26 2023 +0200 +++ b/scanf/doscan.c Sat Sep 16 18:40:28 2023 +0200 @@ -761,6 +761,7 @@ } done: + va_end (ap); (*__gmp_free_func) (alloc_fmt, alloc_fmt_size); return fields; } ~/src/gmp$ On the printf/doprnt.c side, I'm not sure. There is a "va_copy (ap" at the beginning, so we can va_end before returning. Each loop starts with a "va_copy (this_ap" and can end with a corresponding va_end. But last_ap is va_copy-ed again and again; should we insert a va_end before each new copy? I attach a possible patch for printf/doprnt.c . Ĝis, m
diff -r 8225bdfc499f printf/doprnt.c --- a/printf/doprnt.c Tue Sep 05 18:32:26 2023 +0200 +++ b/printf/doprnt.c Sat Sep 16 18:59:51 2023 +0200 @@ -340,6 +340,7 @@ ret = __gmp_doprnt_integer (funs, data, ¶m, gmp_str); __GMP_FREE_FUNC_TYPE (gmp_str, strlen(gmp_str)+1, char); DOPRNT_ACCUMULATE (ret); + va_end (last_ap); va_copy (last_ap, ap); last_fmt = fmt; } @@ -372,6 +373,7 @@ DOPRNT_ACCUMULATE (__gmp_doprnt_mpf (funs, data, ¶m, GMP_DECIMAL_POINT, va_arg (ap, mpf_srcptr))); + va_end (last_ap); va_copy (last_ap, ap); last_fmt = fmt; break; @@ -494,6 +496,7 @@ case 'Z': mpz_set_si ((mpz_ptr) p, (long) retval); break; } } + va_end (last_ap); va_copy (last_ap, ap); last_fmt = fmt; goto next; @@ -604,7 +607,7 @@ next: /* Stop parsing the current "%" format, look for a new one. */ - ; + va_end (this_ap); } TRACE (printf ("remainder: \"%s\"\n", last_fmt)); @@ -616,6 +619,8 @@ goto error; done: + va_end (last_ap); + va_end (ap); __GMP_FREE_FUNC_TYPE (alloc_fmt, alloc_fmt_size, char); return retval;
_______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org https://gmplib.org/mailman/listinfo/gmp-devel