Bug 16565 – Implementing an interface with preconditions causes segfault
Status
RESOLVED
Resolution
DUPLICATE
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-09-29T12:18:00Z
Last change time
2016-09-29T14:09:07Z
Assigned to
nobody
Creator
belka
Comments
Comment #0 by belka — 2016-09-29T12:18:37Z
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 by dfj1esp02 — 2016-09-29T14:09:07Z
*** This issue has been marked as a duplicate of issue 15984 ***