www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21598] New: checkaction=context reruns pure functions with

https://issues.dlang.org/show_bug.cgi?id=21598

          Issue ID: 21598
           Summary: checkaction=context reruns pure functions with debug
                    blocks on failure
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: moonlightsentinel disroot.org

===========================================
extern(C) int puts(const scope char*);

void main()
{
    assert(foo(1));
}

int foo(int i) pure nothrow
{
    debug puts("Hello");
    return i - 1;
}
============================================
Currently outputs:
Hello
Hello

This is caused by dmd omitting the temporary for pure function calls
(op.hasSideEffect == false).

--
Jan 31 2021