[Issue 8734] New: Compiler must verify exe path is writable before attempting compilation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 28 18:29:37 PDT 2012


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

           Summary: Compiler must verify exe path is writable before
                    attempting compilation
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-09-28 18:30:07 PDT ---
Windows example:

test1.d:
module test;

import std.stdio;
import std.process;

void main()
{
    system("echo > test.exe");
    auto file = File("test.exe", "r");
    system("dmd test2.d -oftest.exe");
}

test2.d:
module test2;

import std.string;
string mixMe()
{
    string res;
    foreach (i; 0 .. 3_000)
        res ~= xformat("int i_%s;", i);
    return res;
}

mixin(mixMe());

void main()
{
}

$ rdmd test1.d
OPTLINK (R) for Win32  Release 8.00.12
Copyright (C) Digital Mars 1989-2010  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Error 3: Cannot Create File test.exe
--- errorlevel 1

test2.d demonstrates a module that takes a longer while to compile. test1.d
creates a phony test.exe, then opens it in read-mode to lock it. Then it
attempts to compile test2.d and write over test.exe.

DMD will first compile test2.d and only then attempt to write to test.exe and
fail. This can be a considerate waste of time, the compiler should check if the
output location is writable *before* attempting to compile.

-- 
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