Bug 15568 – Wrong contracts generated when compiled with -O
Status
RESOLVED
Resolution
WORKSFORME
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-01-14T15:40:00Z
Last change time
2016-10-01T11:47:06Z
Assigned to
nobody
Creator
dragoscarp
Comments
Comment #0 by dragoscarp — 2016-01-14T15:40:18Z
The PR https://github.com/D-Programming-Language/dmd/pull/4788 fixing issue https://issues.dlang.org/show_bug.cgi?id=9383 introduced a regression that can be reproduced with the following test:
---
import std.algorithm;
import std.array;
class A
{
B foo(C c, D[] ds, bool f)
in
{
assert(c !is null);
}
body
{
D[] ds2 = ds.filter!(a => c).array;
return new B(ds2, f);
}
}
class B
{
this(D[], bool)
{
}
}
class C
{
}
struct D
{
}
unittest
{
auto a = new A;
C c = new C;
a.foo(c, null, false);
}
---
It runs successfully when it is compiled with:
dmd -unittest -main
But the contract throws AssertError when compiled with:
dmd -unittest -main -O
Comment #1 by k.hara.pg — 2016-04-15T11:49:37Z
Issue doesn't happen in Windows platform -m32 and -m64, with git-master:
90becf651dddf4b17c1775c7c0d6ba879fb10090