Bug 6407 – take(map) problem

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-07-30T06:55:00Z
Last change time
2013-07-01T12:49:39Z
Keywords
wrong-code
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-07-30T06:55:01Z
D2 code: import std.stdio, std.algorithm, std.range; auto foo(int p) { return map!((int n){ return p; })(iota(3)); } void main() { writeln(take(foo(2), 20)); } To me it prints: [4221068, 4221068, 4221068]
Comment #1 by bearophile_hugs — 2011-07-31T07:01:58Z
A comment by Daniel Murphy: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=28553 > The problem is the parameter p is not being heap allocated. I'm fairly sure > it's already in bugzilla, something about failing to detect escaping > references with alias parameters.
Comment #2 by hsteoh — 2013-07-01T12:12:15Z
This bug appears to be fixed in latest git HEAD (and probably last release as well)? Bearophile, could you re-test this against the latest release and close the bug if it doesn't happen anymore?
Comment #3 by monarchdodra — 2013-07-01T12:49:39Z
(In reply to comment #2) > This bug appears to be fixed in latest git HEAD (and probably last release as > well)? Bearophile, could you re-test this against the latest release and close > the bug if it doesn't happen anymore? Works for me for as far back as at least 2.061. I'll close it.