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

--- Comment #0 from Brad Anderson <> 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(, a);

Similar code can also produce access violations as can be seen here:

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

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to