[Issue 10854] debug should also bypass safety and nothrow

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 19 13:05:41 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10854



--- Comment #3 from bearophile_hugs at eml.cc 2013-08-19 13:05:40 PDT ---
(In reply to comment #2)

> Also, I don't think the new pure definitions
> mean a pure function can be outright optimized out. But I'm unsure.

The DMD compiler completely optimizes out strongly pure functions in some
situations. And I expect better optimizers to remove some more calls. Observe:


import std.stdio;

int sqr(in int x) pure nothrow {
    debug printf("sqr\n");
    return x ^^ 2;
}

int twoSqr(in int x) pure nothrow {
    return sqr(x) + sqr(x);
}

void main() {
    writeln(twoSqr(3));
}



...>dmd -debug -run test.d
sqr
sqr
18

...>dmd -O -release -debug -run test.d
sqr
18

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list