[Issue 7978] New: UTF exception (memory corruption?) using std.range.chain (behavior changes with -g)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 23 21:01:42 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7978
Summary: UTF exception (memory corruption?) using
std.range.chain (behavior changes with -g)
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: eco at gnuk.net
--- Comment #0 from Brad Anderson <eco at gnuk.net> 2012-04-23 21:02:41 PDT ---
Compiling the following code using DMD 2.059 without -g results in a UTF
exception (memory corruption?) after outputting ["a", "b",. Compiling with -g
produces no exception but the output is incorrect (["a", "b", "0", "1", "2"]
should be ["a", "b", "a0", "a1", "a2"]). Now, if you replace the iota line
with with the commented out sequence line it works the other way. Without -g
gives no exception (but correct output this time), with -g results in a UTF
exception. It's a bit unsettling that adding debug info can change the behavior
of the program.
import std.stdio, std.range, std.algorithm, std.string;
void main()
{
writeln(gen(["a", "b"]).take(5));
}
auto gen(string[] lst)
{
auto prefix = lst[0];
auto a = iota(10).map!(a=>format("%s%d", prefix, a))();
//auto a = sequence!"n+1"().map!(a=>format("%s%d", prefix, a))();
return chain(lst.save, a);
}
Similar code can also produce access violations as can be seen here:
http://forum.dlang.org/post/owqlhtpfnxjujwuxkeob@forum.dlang.org
I'm not sure how to go about reducing this. Sometimes I can get it to work
(using a global fixed it in one case though wasn't suitable for my needs).
Moving it out of its own function into main() also fixes it sometimes but not
always.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list