bug-gnulib
[Top][All Lists]
Advanced

[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: Tue, 29 Nov 2011 00:39:38 +0100
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Hi Matthew,

> e->short_options += (short_options - hol->short_options);
> 
> subtracts two pointers that do not point to the same memory object.
> Something like:
> 
> e->short_options = short_options + (e->short_options - hol->short_options);
> 
> does the intended operation with legal pointer arithmetic.

Thanks for the suggestion.

However, I find the existing code easier to understand than the one you
propose. Therefore, to understand the possible impact, a question:

Do you know of any platforms where sizeof (ptrdiff_t) < sizeof (void *) ?

Bruno
-- 
In memoriam Wasfi al-Tal <http://en.wikipedia.org/wiki/Wasfi_al-Tal>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]