Created attachment 1087
Test case crashing the compiler
Class C inherits from B which inherits from A. All three classes define the
same function. A and B specifies an out contract on the function (C may or may
not specify an out contract, it doesn't matter). In this case, dmd crashes
without error message, and doesn't generate the .exe file.
Here is the verbose output:
$ dmd -v e
binary C:\D\dmd2\windows\bin\dmd.exe
version v2.058
config C:\D\dmd2\windows\bin\sc.ini
parse e
importall e
import object
(C:\D\dmd2\windows\bin\..\..\src\druntime\import\object.di)
semantic e
semantic2 e
semantic3 e
At this point it just stops. The rest of the output should have been as
follows, if I remove one of the two contracts:
code e
function e.A.foo
function e.A.foo.__ensure
function e.B.foo
function e.C.foo
function D main
C:\D\dmd2\windows\bin\link.exe e,,nul,user32+kernel32/noi;
Comment #1 by dlang — 2012-04-10T03:18:09Z
Note the attached file has commented out one of the contracts and thus compiles; remove the "//" and the crash arises.
Here is the Windows 7 crash information:
Problem signature:
Problem Event Name: APPCRASH
Application Name: dmd.exe
Application Version: 0.0.0.0
Application Timestamp: 00000000
Fault Module Name: dmd.exe
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Code: c0000005
Exception Offset: 0004d784
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1044
Additional Information 1: c0d2
Additional Information 2: c0d2fd7c47233db608dcc0a8dfa7e295
Additional Information 3: 77a4
Additional Information 4: 77a4546d10565e53c3340bd335ee63b4
Comment #2 by dlang — 2012-04-10T03:19:46Z
By the way, the test case compiles fine with gdc
Comment #3 by dlang — 2012-04-10T07:06:35Z
Comment on attachment 1087
Test case crashing the compiler
This file compiles as it stands; remove the "//" to make it crash dmd.
Comment #4 by lovelydear — 2012-04-21T11:21:34Z
The test case is:
class A {
int foo(int i)
out (result) { }
body { return 1; }
}
class B : A {
int foo(int i)
// out (result) { }
body { return 1; }
}
class C : B {
int foo(int i) { return 1; }
}
void main() {
}
It compiles and runs on DMD 2.059 Win32
Comment #5 by dlang — 2012-04-21T11:52:23Z
(In reply to comment #4)
> It compiles and runs on DMD 2.059 Win32
Hi,
Could you check this one also please?
By mistake the file I uploaded had commented out one of the contracts, and then the file does indeed work. It is only when both contracts are in place, that dmd crashes.
class A {
int foo(int i)
out (result) { }
body { return 1; }
}
class B : A {
int foo(int i)
out (result) { }
body { return 1; }
}
class C : B {
int foo(int i) { return 1; }
}
void main() {
}
Comment #6 by lovelydear — 2012-04-21T12:13:38Z
(In reply to comment #5)
> (In reply to comment #4)
> > It compiles and runs on DMD 2.059 Win32
>
> Hi,
>
> Could you check this one also please?
> By mistake the file I uploaded had commented out one of the contracts, and then
> the file does indeed work. It is only when both contracts are in place, that
> dmd crashes.
>
Yes, it crashes DMD Win32 here too.
Comment #7 by clugdbug — 2012-05-14T03:16:38Z
Also crashes on D1 Linux.
It's in func.c(1987), in FuncDeclaration::mergeFensure(Statement * sf)
fensure is NULL (In fact, it's called with fensure = mergeFensure(fensure)
if (sf)
{
sf = new CompoundStatement(fensure->loc, s2, sf);
}
Changing this to sf->loc prevents the segfault. But, there's something else wrong -- after this change, it prints
bug.d(21): Error: undefined identifier result
whereas it should compile without error.