www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - inline bug of final class (dmd 0.131 win32)

reply zwang <nehzgnaw gmail.com> writes:
D:\d\tctr>type main.d
import std.stdio;
int r = 1;
class B{
         void f(){
                 writefln("B.f");
         }
}
final class D : B{
         void f(){
                 --r;
                 writefln("D.f");
                 super.f();
         }
}
int main(){
         (new D).f();
         if(r)
                 writefln("bug!");
         return r;
}

D:\d\tctr>dmd main.d
C:\dmd\bin\..\..\dm\bin\link.exe main,,,user32+kernel32/noi;

D:\d\tctr>main
D.f
B.f

D:\d\tctr>dmd main.d -inline
C:\dmd\bin\..\..\dm\bin\link.exe main,,,user32+kernel32/noi;

D:\d\tctr>main
D.f
D.f
B.f
bug!

D:\d\tctr>


Remarks: The bug disappears when the keyword "final" is removed
from the source.
Sep 09 2005
parent =?ISO-8859-1?Q?Thomas_K=FChne?= <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

zwang schrieb:

 D:\d\tctr>type main.d
 import std.stdio;
 int r = 1;
 class B{
         void f(){
                 writefln("B.f");
         }
 }
 final class D : B{
         void f(){
                 --r;
                 writefln("D.f");
                 super.f();
         }
 }
 int main(){
         (new D).f();
         if(r)
                 writefln("bug!");
         return r;
 }
 
 D:\d\tctr>dmd main.d
 C:\dmd\bin\..\..\dm\bin\link.exe main,,,user32+kernel32/noi;
 
 D:\d\tctr>main
 D.f
 B.f
 
 D:\d\tctr>dmd main.d -inline
 C:\dmd\bin\..\..\dm\bin\link.exe main,,,user32+kernel32/noi;
 
 D:\d\tctr>main
 D.f
 D.f
 B.f
 bug!
 
 D:\d\tctr>
 
 
 Remarks: The bug disappears when the keyword "final" is removed
 from the source.
Added to DStress as http://dstress.kuehne.cn/run/i/inline_14_A.d http://dstress.kuehne.cn/run/i/inline_14_B.d http://dstress.kuehne.cn/run/i/inline_14_C.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDInnW3w+/yD4P9tIRApWKAJ9CR26BliLJ2IsUBr4Tc0uSK8DN1gCeJqzy TOCuZlJqGh76/Xsfk3mkZLI= =Z+eN -----END PGP SIGNATURE-----
Sep 09 2005