www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18988] New: Reading from unreadable file results in random

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

          Issue ID: 18988
           Summary: Reading from unreadable file results in random garbage
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: elpenguino+D gmail.com

Attempting to read from a file opened only for writing on Windows (10, build
17134, 64-bit) after writing to the file does not throw an exception when read
from, nor does it produce a valid result.


```
import std.stdio;

void main()
{
    auto x = File("hi", "w");
    x.write("Hello.");
    ubyte[4096] buf;
    auto slice = x.rawRead(buf);
    assert(slice.length == 0); //Fails.
    assert(slice == new ubyte[](slice.length)); //Also fails.
}
```

This only occurs when compiled with -m32. -m32mscoff and -m64 throw exceptions
as expected.

--
Jun 14 2018