foreach(line; f.byLine) produces core.exception.InvalidMemoryOperationError@(0) in 2.067 but not 2.066

Daniel Kozák via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 15 07:18:59 PDT 2015


On Tue, 15 Sep 2015 13:56:36 +0000
Andrwe Brown via Digitalmars-d-learn
<digitalmars-d-learn at puremagic.com> wrote:

> Hi,
> 
> I'm trying to read a file line by line, and I get a 
> core.exception.InvalidMemoryOperationError@(0), even after 
> reducing the program to:
> 
> import std.stdio;
> 
> void main()
> {
>    File f = File("testfile");
>    foreach(line; f.byLine)
>    {
>    }
> }
> 
> The file is a simple table of ascii characters, 811 columns and 
> it fails on the second line. Taking any subset of the columns and 
> the program runs fine so I don't think it can by any particular 
> file corruption.
> 
> In this simple example I can get it to work by changing:
> 
> foreach(line; f.byLine)
> 
> to
> 
> foreach(char[] line; f.byLine)
> 
> but in my more complicated program this still fails with the same 
> error:
> 
> foreach (char[] lineVar; inFile.byLine)
> {
>    lineVar.split.indexed(places).joiner("\t").writeln;
> }
> 
> (as does the range version I originally wrote:
> inFile.byLine.map!(a => 
> a.split.indexed(places).joiner("\t")).joiner("\n").writeln;)
> 
> Is this a bug, gdc on version 2.066 seems to have no problems 
> with it? I'd be happy to fill in a bug report, but I can't share 
> the file as it's sensitive genetic data and I haven't been able 
> to reduce it to anything innocuous.
> 
> This has me very puzzled, any suggestions would be much 
> appreciated.
> 
> Thanks very much
> 
> Andrew

Which OS?


More information about the Digitalmars-d-learn mailing list