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 00:24, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Thu, Mar 16, 2017 at 5:00 PM, Dibyendu Majumdar
> <mobile@xxxxxxxxxxxxxxx> wrote:
>>
>> The cast to double has been removed. I am trying to understand where
>> this is happening as it seems to happen quite early on. Any tips on
>> where I should look?
>
> Since sparse was mostly done for kernel stuff, there's almost no
> floating point support anywhere.
>

So far the tests with floating points I have been running appear to
work after some fixes to sparse-llvm. This is the first one that seems
to be an upstream issue. I have found a floating point paranoia test
in the lcc compiler test suite - hopefully once I adapt this to run
with sparse-llvm it will help tease out any other bugs.

> 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.

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