[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: undefined behavior in hol_append()
From: |
Bruno Haible |
Subject: |
Re: undefined behavior in hol_append() |
Date: |
Wed, 30 Nov 2011 01:47:31 +0100 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
Paul Eggert wrote:
> > Do you know of any platforms where sizeof (ptrdiff_t) < sizeof (void *) ?
>
> The standard operating mode for ILE C/C++ (for IBM i)
> has 16-byte pointers; I expect that sizeof (ptrdiff_t)
> is 8 and sizeof (void *) is 16 on such platforms, though
> I don't have a short citation supporting this.
Thanks for the reference. This is a platform that's in use today. So I'm
applying Matthew's suggestion.
Matthew, the "(tiny change)" annotation is not meant to be derogatory. It
simply states that no exchange of legal paperwork was needed for integrating
your patch.
2011-11-29 Matthew Wala <address@hidden> (tiny change)
Avoid subtracting two pointers that don't point into the same block.
* lib/argp-help.c (hol_append): Reorder pointer subtractions so that
only pointers into the same memory block are subtracted. We cannot
assume that sizeof (ptrdiff_t) == sizeof (void *).
--- lib/argp-help.c.orig Wed Nov 30 01:39:20 2011
+++ lib/argp-help.c Wed Nov 30 01:37:25 2011
@@ -891,7 +891,8 @@
/* 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. */
--
In memoriam Willy Cohn <http://de.wikipedia.org/wiki/Willy_Cohn>