qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/5] softfloat: Fix warn about implicit conversi


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 2/5] softfloat: Fix warn about implicit conversion from int to int8_t
Date: Wed, 10 Aug 2016 14:12:35 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0


On 10/08/2016 12:37, Peter Maydell wrote:
> On 10 August 2016 at 11:32, Richard Henderson <address@hidden> wrote:
>> On 08/10/2016 12:32 AM, Pranith Kumar wrote:
>>>
>>>  typedef struct float_status {
>>> +    int         float_exception_flags;
>>>      signed char float_detect_tininess;
>>>      signed char float_rounding_mode;
>>> -    signed char float_exception_flags;
>>
>>
>> Given that there are no flags outside 8 bits, why is this supposed to help?
> 
> It's just consistency -- using the same type all the way through
> from the set_float_exception_flags() prototype to the field
> in the structure. When we were discussing this on IRC that
> seemed a reasonable approach to me.
> 
> What clang is specifically warning about is if you pass
> float_flag_output_denormal to set_float_exception_flags():
> that's a positive number (128), which gets implicitly
> converted to a negative number when it's assigned to
> the signed char. Using a type wide enough to store
> 128 all the way through fixes this. (Unsigned char would
> work too.)

That seems better.  By the way this use of "signed char" is a real bug;
get_float_exception_flags is returning a sign-extended value, which is
turned into a positive value here:

  if(nRc == 1 && get_float_exception_flags(&fpa11->fp_status))
  {
    //printf("fef 0x%x\n",float_exception_flags);
    nRc = -get_float_exception_flags(&fpa11->fp_status);
  }

  //printf("returning %d\n",nRc);
  return(nRc);

Thanks,

Paolo



reply via email to

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