From: Paul Eggert Date: Fri, 19 May 2017 22:35:24 +0000 (-0700) Subject: argp: fix pointer-subtraction bug X-Git-Tag: v1.0~6131 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=a50e906c0c046c57938f786ffb82b36beea75043;p=gnulib.git argp: fix pointer-subtraction bug * lib/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 --- diff --git a/ChangeLog b/ChangeLog index 889ef119a5..b214252007 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2017-05-19 Paul Eggert + + argp: fix pointer-subtraction bug + * lib/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 + 2017-05-19 Bruno Haible printf-posix tests: Avoid test failure with "gcc --coverage". diff --git a/lib/argp-help.c b/lib/argp-help.c index 06329606a7..ce9bab9637 100644 --- a/lib/argp-help.c +++ b/lib/argp-help.c @@ -880,7 +880,8 @@ hol_append (struct hol *hol, struct hol *more) /* Fix up the short options pointers from HOL. */ 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 too. */