[Issue 6329] Out of range exceptions not thrown in certain cases

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 12 16:35:53 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6329



--- Comment #7 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-10-12 16:35:00 PDT ---
Here's more issues, this time the sample tries to write to a file handle that
was opened in read-only mode:

import std.stdio;
import std.file;

void main()
{
    foreach (string entry; dirEntries(".", SpanMode.shallow))
    {
        auto file = File(entry, "r");

        string[] lines;
        foreach (line; file.byLine)
        {
            lines ~= line.idup;
        }

        foreach (line; lines)
        {
            file.writeln("asdf");
        }
    }
}

$ dmd test.d && test.exe

Nothing is outputted. But with -g:

$ dmd -g test.d && test.exe
$
std.exception.ErrnoException at D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(1164):
 (No error)

So without the symbolic info I get nothing in stdout. However If I change the
sample to this:

import std.stdio;
import std.file;

void main()
{
    foreach (string entry; dirEntries(".", SpanMode.shallow))
    {
        auto file = File(entry, "r");
        file.writeln("asdf");
    }
}

$ dmd test.d && test.exe
object.Error: Access Violation
..

and this error message will loop forever.

But with -g I only get one error message as it should be:
$ dmd -g test.d && test.exe
$
std.exception.ErrnoException at D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(1164):
 (No error)

So I'll just have to compile with -g all the time until this gets resolved.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list