[Issue 18275] New: dmd deletes source file fun.cpp with `dmd fun.cpp.o main.d`

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 22 03:31:27 UTC 2018


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

          Issue ID: 18275
           Summary: dmd deletes source file fun.cpp with `dmd fun.cpp.o
                    main.d`
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: timothee.cour2 at gmail.com

```
fun.cpp:extern"C" void test(){}
main.d:extern(C) void test(); void main(){}
```

clang++ -o fun.cpp.o -c fun.cpp
dmd fun.cpp.o main.d

(same bug with ldc2)
this caused https://github.com/Syniurge/Calypso/issues/59

proposed fix:
if `-of` explicitly passed on cmd line, fine, nothing to check

if not, infer output file as we already do, but first assert(!file.exists)
(regardless of what type of file it is, that's irrelevant)

downside:
dmd main2.d
#creates main2
dmd main2.d
#error main2 already exists, please specify -of=main2 explicitly to force write

I think the downside is not as bad as the bug I reported which deletes source
code and can be very damaging if the file wasn't backed up in its latest form,
which is common in edit/compile/debug cycles

--


More information about the Digitalmars-d-bugs mailing list