Re: Strange expl results

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

 



The value bits differ, memset will not help here. You can watch the values
in the gdb:

(gdb) n
43          printBits(sizeof(r1), &r1);
(gdb) info locals
c = -1
r1 = 0.36787944117144232158305751367866065
r2 = 0.36787944117144232161016256799079827

пт, 27 нояб. 2020 г. в 00:54, Stefan Ring <stefanrin@xxxxxxxxx>:

> On Thu, Nov 26, 2020 at 9:21 PM Alex Markin via Gcc-help
> <gcc-help@xxxxxxxxxxx> wrote:
> >
> > Hello.
> >
> > I don't know if it is a gcc or binutils problem. I have different results
> > for `expl' function depending on the argument was variable or literal:
> >
> > long double c, r1, r2;
> > r1 = expl(-1);
> >
> > c = -1;
> > r2 = expl(c);
> >
> > In this example r1 and r2 differ in the lower bits. The entire example is
> > here: https://godbolt.org/z/xqn4bd. The llvm does not have such a
> problem.
>
> The reason is that the Intel-specific 80 bit long double format is
> used. So the first 80 bits of r1 and r2 contain the value, and the
> rest remains uninitialized. You could memset both to 0 first, then the
> comparison would check out. I'm sure there is a good reason for sizeof
> producing 16, not 10.
>




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux