www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8957] New: Closure not recognized when passing type with post-blit as lazy parameter

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8957

           Summary: Closure not recognized when passing type with
                    post-blit as lazy parameter
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code klickverbot.at



PDT ---
This is a follow-up to the thread »Expression::apply, DeclarationExp and a
possible nested context bug« on dmd-internals:
http://forum.dlang.org/thread/CAP9J_HXG8mTtnojU9YwYuSGZp1NQCdY0+7oeHyoQ2WhNR-dAuw mail.gmail.com

The following test case shows that the problem I brought up there there also
leads to wrong-code bugs in DMD (at least I hope it's still the original
problem, I simply extended this from the minimal testcase linked in the
thread):

---
extern(C) void printf(const char*, ...);

struct HasPostblit {
    this(this) {};
}

struct Foo {
    HasPostblit hp;
    int i;
}

void print(Foo f) {
    printf("%x\n", f.i);
}

auto toDg(E)(lazy E e) {
    return { return e(); };
}

auto getDg() {
    Foo a;
    a.i = 0x1;
    return toDg(print(a));
}

void smashStack() {
    int[1024] dummy = 0xcafebabe;
}

void main() {
    auto d = getDg();
    smashStack();
    d();
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 03 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8957




Quite likely to be related to at least one of the other closure bugs:
bug 1841, bug 1759, bug 2148, bug 6141.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 05 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8957




PST ---
 Don: For an analysis of why this happens and a minimal test case, see the
linked dmd-internals thread (I'm fairly sure that it is correct, having spent
quite some time tracking down the issue in LDC). As to whether this is related
to the other bugs, I'm not sure OTOH if an intermediary DeclarationExp is also
generated for them.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 11 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8957


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com
           Severity|normal                      |major


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 11 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8957


Iain Buclaw <ibuclaw ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw ubuntu.com



Partial fix.

https://github.com/D-Programming-Language/dmd/pull/1854

What changes is that 'Foo a' is now added to closureVars for the function
getDg().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 06 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8957




13:04:05 PDT ---

 Partial fix.
What is left undone? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 06 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8957




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/bea22e33b11ac8efd07081f43fac1d54d2a9aab2


Check declaration initializer expressions for nested refs.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 06 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8957






 Partial fix.
What is left undone?
Detection in FuncDeclaration:: needsClosure. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 06 2013