[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft-devel] Undefined behavior
From: |
Behdad Esfahbod |
Subject: |
Re: [ft-devel] Undefined behavior |
Date: |
Mon, 11 Aug 2014 14:42:56 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 |
On 14-08-11 02:13 PM, Alexei Podtelezhnikov wrote:
> On Mon, Aug 11, 2014 at 11:55 AM, Behdad Esfahbod <address@hidden> wrote:
>> On 14-08-11 10:15 AM, Alexei Podtelezhnikov wrote:> On Fri, Aug 8, 2014 at
>> 4:56 PM, Behdad Esfahbod <address@hidden> wrote:
>>>> commit 177982e933ed6f2ab96163e14f4267f8abe89efd
>>>
>>> Seriously though, my commit does not change much, both FT_MSB and
>>> ft_highpow2 used to return nonsense on zero input even before this
>>> commit. I think I am going to apply some patches to protect against
>>> reaching this code with zero argument, but I am not willing to change
>>> FT_MSB itself.
>>
>> Non-sense is not the same as undefined. FT_MSB used to return 0 for 0. Now
>> it's undefined. See below.
>
> Ok. I still do not think that we should fix the macro, because there
> is no good value to return. Returning zero for zero is bad too. One
> should not call MSB or the builtins with zero argument, just like one
> should not divide by zero. So I'll try to apply fix the callers.
It's sometimes more convenient to have such defined behaviors as returning 0
for 0 in MSB as it makes caller code both cleaner and safer, like what was
there before.
--
behdad
http://behdad.org/
Re: [ft-devel] Undefined behavior, Alexei Podtelezhnikov, 2014/08/11