[Issue 14363] DMD should compile SDC test0165.d

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Mar 28 21:55:25 PDT 2015


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

--- Comment #2 from Shammah Chancellor <shammah.chancellor at gmail.com> ---
Your code has a bug?

return new B(5);

Should be:

return new B();


With that, your example compiles and works just fine on SDC.


(In reply to Kenji Hara from comment #1)
> I'm not sure why SDC accepts the code.
> 
> The following reduced case is correctly rejected by dmd, because ba.foo()
> won't work expectedly. Maybe SDC generates wrong code?
> 
> void main()
> {
>     uint x = 7;
> 
>     class A
>     {
>         auto foo()
>         {
>             return x;
>         }
>     }
> 
>     auto makeB(uint y)
>     {
>         class B : A
>         {
>             auto bar()
>             {
>                 return foo() + y;
>             }
>         }
> 
>         return new B(5);
>     }
> 
>     A a = new A();
>     assert(a.foo() == 7);
> 
>     auto b = makeB(3);
>     assert(b.bar() == 10);
> 
>     A ba = b;
>     assert(ba.foo() == 7);
> }

--


More information about the Digitalmars-d-bugs mailing list