[Issue 11506] pure evaluation should be shortcircuited

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 13 12:22:35 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11506


Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com


--- Comment #4 from Walter Bright <bugzilla at digitalmars.com> 2013-11-13 12:22:31 PST ---
Yes, bearophile's right, I forgot about nothrow.

But the compiler is a bit conservative by requiring nothrow. For throwing pure
functions, the foo()+foo() case can still be replaced with 2*foo() if the
arguments to foo are identical, even if foo throws. The obvious case of this is
the no-argument case, which bearophile mentioned.

Also, if foo() returns memory that it new'd, it cannot be elided:

    pure nothrow string foo();
    return foo() ~ foo();

so things are a bit complicated, but there's still optimization opportunity.

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


More information about the Digitalmars-d-bugs mailing list