Re: Cast to double being removed

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

 



Hi Linus,

On 17 March 2017 at 10:38, Dibyendu Majumdar <mobile@xxxxxxxxxxxxxxx> wrote:
> On 17 March 2017 at 00:24, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>> There's something seriously screwed up with explicit double casting.
>> See the differences between
>>
>>   double f1(void) { return -1; }
>>   double f2(void) { return (double)-1; }
>>   double f3(void) { return -1.0; }
>>
>> and notice how the first one and third ones actually kind-of make
>> sense. The second one? Not so much, it just uses a 64-bit integer.
>>
>> The bug is already at the parse tree stage, the linearization doesn't
>> even see the cast.
>>
>> I think it's this, in simplify_cast():
>>
>>         /* A cast of a constant? */
>>         if (constant(src)) {
>>                 int sign = orig_type->ctype.modifiers & MOD_SIGNED;
>>                 long long val = get_cast_value(src->value, orig_size,
>> size, sign);
>>                 src = value_pseudo(val);
>>                 goto simplify;
>>         }
>>
>> which doesn't even check whether it's a FP value, it just looks if
>> it's a constant and assumes it's an integer. At least it checks the
>> sign ;)
>>
>
> Thank you for pointing me to the location where the issue might be.
>

It seems that not only here but elsewhere also during simplification
of expressions involving constants there is no check whether the
instruction type is floating point. As a test I simply disabled the
simplification if the instruction type is floating point. Good news is
that while before the paranoia test was hanging and giving many
errors, but now it says:

No failures, defects nor flaws have been discovered.
Rounding appears to conform to the proposed IEEE standard P754.
The arithmetic diagnosed appears to be Excellent!
END OF TEST.

Regards
Dibyendu
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux