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

2015-09-15 Thread Andrew Brown via Digitalmars-d-learn
Thanks very much for your help, it seemed to work a treat (I hope 
:))! Compiling ldc wasn't too bad, make the changes to 
runtime/phobos/std/stdio.d and then just building as normal was 
no problem. Unittests are passing and it handles that file 
perfectly.


On Tuesday, 15 September 2015 at 16:11:06 UTC, Martin Krejcirik 
wrote:
On Tuesday, 15 September 2015 at 15:28:23 UTC, Andrew Brown 
wrote:
A very naive question: would it be possible in this case to 
backport it into gdc/ldc by copying the pull request and 
building the compiler from source, or would this get me into a 
world of pain?


Cherry-picking should work and merge cleanly. I have done it 
for DMD 2.067. I don't know how difficult it is to recompile 
Phobos and Druntime with LDC/GDC though.





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

2015-09-15 Thread Martin Krejcirik via Digitalmars-d-learn

For reference, it was this PR:
https://github.com/D-Programming-Language/phobos/pull/3089
which fixed the same issue for me.



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

2015-09-15 Thread Martin Krejcirik via Digitalmars-d-learn

On Tuesday, 15 September 2015 at 15:28:23 UTC, Andrew Brown wrote:
A very naive question: would it be possible in this case to 
backport it into gdc/ldc by copying the pull request and 
building the compiler from source, or would this get me into a 
world of pain?


Cherry-picking should work and merge cleanly. I have done it for 
DMD 2.067. I don't know how difficult it is to recompile Phobos 
and Druntime with LDC/GDC though.


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

2015-09-15 Thread Andrew Brown via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 14:55:42 UTC, Martin Krejcirik 
wrote:

For reference, it was this PR:
https://github.com/D-Programming-Language/phobos/pull/3089
which fixed the same issue for me.


A very naive question: would it be possible in this case to 
backport it into gdc/ldc by copying the pull request and building 
the compiler from source, or would this get me into a world of 
pain?


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

2015-09-15 Thread Daniel Kozák via Digitalmars-d-learn

On Tue, 15 Sep 2015 13:56:36 +
Andrwe Brown via Digitalmars-d-learn
 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?


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

2015-09-15 Thread Martin Krejcirik via Digitalmars-d-learn

On Tuesday, 15 September 2015 at 13:56:37 UTC, Andrwe Brown wrote:
I'm trying to read a file line by line, and I get a 
core.exception.InvalidMemoryOperationError@(0), even after


https://issues.dlang.org/show_bug.cgi?id=13856

Try DMD 2.068, it has got fixed byLine implementation.




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

2015-09-15 Thread Andrew Brown via Digitalmars-d-learn

On Tuesday, 15 September 2015 at 14:19:13 UTC, Daniel Kozák wrote:


Which OS?


It's CentOS release 6.5 (Final), I tried dmd 2.068.1 and the 
problem has disappeared. Thanks very much for the advice, I can 
stick to old gdc for speed until ldc catches up to 2.068.


Best

Andrew


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

2015-09-15 Thread Andrwe Brown via Digitalmars-d-learn

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