D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7290 - Heap allocation with scoped delegate literal
Summary: Heap allocation with scoped delegate literal
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-14 00:55 UTC by Martin Nowak
Modified: 2012-01-17 23:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Martin Nowak 2012-01-14 00:55:28 UTC
int foo(alias pred)(int val)
{
    return pred(val);
}

int bar(int val)
{
    scope pred = (int a) => a + val; //<- causes allocation
    return foo!(pred)(2);
}

void main()
{
    bar(3) == 5 || assert(0);
}

----

Related to resolved
http://d.puremagic.com/issues/show_bug.cgi?id=7120