www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Bug in std.stream in DMD v0.125

The following program causes erratic behaviour with std.stream:

import std.stream;

void main()
	static const char[] FILENAME = "test.bin";
	static const uint NUM = 0x7F;
	File f = new File(FILENAME, FileMode.In | FileMode.Out);
	Stream s = f;
	f.seek(0, SeekPos.Set);
	uint x, y;
	f.seek(0, SeekPos.Set);
	printf("NUM:\t%u\nx:\t%u\ny:\t%u\n", NUM, x, y);

The program outputs:

NUM:    127
x:      127
y:      0

For some reason, y is 0 when it of course should be 127. Consecutive 
Stream.read calls with a uint argument set the argument's value to 0. 
This doesn't happen with int arguments.
May 24 2005