argp: fix pointer-subtraction bug

* argp/argp-help.c (hol_append): Don't subtract pointers to
different arrays, as this can run afoul of -fcheck-pointer-bounds.
See the thread containing Bruno Haible's report in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-05/msg00171.html

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
This commit is contained in:
Paul Eggert 2021-01-07 02:06:16 +01:00 committed by Adhemerval Zanella
parent dfc3907cde
commit 5ec029c883

View File

@ -867,7 +867,8 @@ hol_append (struct hol *hol, struct hol *more)
/* Fix up the short options pointers from HOL. */ /* Fix up the short options pointers from HOL. */
for (e = entries, left = hol->num_entries; left > 0; e++, left--) for (e = entries, left = hol->num_entries; left > 0; e++, left--)
e->short_options += (short_options - hol->short_options); e->short_options
= short_options + (e->short_options - hol->short_options);
/* Now add the short options from MORE, fixing up its entries /* Now add the short options from MORE, fixing up its entries
too. */ too. */