On 10/08/2016 12:37, Peter Maydell wrote:
> On 10 August 2016 at 11:32, Richard Henderson <[email protected]> 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