www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19797] New: File.seek() terminates ungracefully on incorrect

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

          Issue ID: 19797
           Summary: File.seek() terminates ungracefully on incorrect
                    origin for -m32mscoff and -m64
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: Bastiaan Veelo.net

The origin parameter to File.seek() should only accept SEEK_STEP, SEEK_CUR or
SEEK_END. When a different int is passed, an exception is correctly thrown when
compiled with -m32. However, on Windows 10 at least, when compiled with either
-m32mscoff or -m64, the process terminates without any message whatsoever.

import std.experimental.all;

void main()
{       
        auto deleteme = "deleteme";
        auto f = File(deleteme, "wb+");
        scope(exit) { f.close(); std.file.remove(deleteme); }
        f.seek(0, 3);   // Should throw.

        writeln("Ending gracefully."); // Never seen.
}

--
Apr 09 2019