GC.malloc is pure - wat

via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 24 10:22:44 PDT 2015


On Friday, 24 April 2015 at 16:34:09 UTC, anonymous wrote:
> On Friday, 24 April 2015 at 15:29:59 UTC, Marc Schütz wrote:
>> auto a = sin(x) * sin(x);    // sin() is called only once
>
> Could you give a complete example of when this is done?
>
> Two calls here (ldc2 -c -O):
>
> real grepme(real x) pure
> {
>     import std.math;
>     auto a = sin(x) * sin(x);
>     return a;
> }
>
> 0000000000000000 <_D4test6grepmeFNaeZe>:
>    0:   48 83 ec 28             sub    rsp,0x28
>    4:   db 6c 24 30             fld    TBYTE PTR [rsp+0x30]
>    8:   d9 c0                   fld    st(0)
>    a:   db 7c 24 10             fstp   TBYTE PTR [rsp+0x10]
>    e:   db 3c 24                fstp   TBYTE PTR [rsp]
>   11:   e8 00 00 00 00          call   16 
> <_D4test6grepmeFNaeZe+0x16>
>   16:   db 7c 24 1c             fstp   TBYTE PTR [rsp+0x1c]
>   1a:   db 6c 24 10             fld    TBYTE PTR [rsp+0x10]
>   1e:   db 3c 24                fstp   TBYTE PTR [rsp]
>   21:   e8 00 00 00 00          call   26 
> <_D4test6grepmeFNaeZe+0x26>
>   26:   db 6c 24 1c             fld    TBYTE PTR [rsp+0x1c]
>   2a:   de c9                   fmulp  st(1),st
>   2c:   48 83 c4 28             add    rsp,0x28
>   30:   c3                      ret

Hmm... strange. I was convinced it worked that way. I used 
`sin()` specifically because I remember I've seen an example with 
it. But now I can't get it do work anymore, not even with `int` 
or a user-defined pure function.


More information about the Digitalmars-d mailing list