D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16565 - Implementing an interface with preconditions causes segfault
Summary: Implementing an interface with preconditions causes segfault
Status: RESOLVED DUPLICATE of issue 15984
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 critical
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-29 12:18 UTC by Eugene Wissner
Modified: 2016-09-29 14:09 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Eugene Wissner 2016-09-29 12:18:37 UTC
If I compile the following program (Naughty.d):

interface Foo
{
    public void delegate() add(Object[] elements)
    in
    {
		foreach (el; elements) {}
    }
}

class FooImpl : Foo
{
    public void delegate() add(Object[] elements)
    in
    {
    }
    body
    {
        return null;
    }
}

void main()
{
	FooImpl bar = new FooImpl;
	bar.add(new Object[2]);
}



and run it I get a Segmentation fault.

Compile command:
dmd -gc -w Naughty.d -L--export-dynamic

DMD version:
DMD64 D Compiler v2.071.2

The segfault happens apparently in the foreach-loop, in the precondition of Foo.add(). It crashes before the first execution of the loop body.

I also had similar errors when putting invariants in some classes or interfaces.
Comment 1 anonymous4 2016-09-29 14:09:07 UTC

*** This issue has been marked as a duplicate of issue 15984 ***