www.digitalmars.com         C & C++   DMDScript  

D.gnu - Bug in std.stdio.readln()

The following code causes a segfault for me on both x86 and amd64 systems.
This happens with both the gentoo 'emerge dev-lang/gcc' with USE=d and with
the gdc 0.24 binary distribution:

======================================================================
module readline;

import std.stdio;

void main ()
{
     while (1) {
	char[] buf = readln ();
	if (buf is null)
	    break;
	writef ("%s", buf);
     }
}
======================================================================

Upon EOF, there is a segfault inside of a string dup inside of readln:

   uint std.stdio.readln(struct std.c.stdio._iobuf*, inout char[])










I can try to build phobos with debugging symbols if other are unable to
reproduce this problem.

I will work around this by reading the file in characters.

Thanks,
David Brown
Sep 30 2007