unimplemented abstract function compiles.

rikki cattermole rikki at cattermole.co.nz
Sat Aug 11 21:20:58 UTC 2018


On 12/08/2018 8:55 AM, Eric wrote:
> Code below compiles while I would not expect it to compile.
> Is there a reason that this compiles?
> 
> Specs are a bit lite on abstract classes.
> Only thing I found that would need to allow this is: "19.4 functions 
> without bodies" https://dlang.org/spec/function.html#function-declarations
> But that's explicitly without the abstract keyword..
> 
> 
> class I {
>    abstract void f();
> }
> 
> class C : I {
> }
> 
> unittest {
>    C c = cast(C) Object.factory("C");
>    c.f();
> }
> 
> 
> I also couldn't find anything about this in the issue tracker.

No bug. You forgot to throw -unittest when you compiled.

/tmp/dmd_run2hTpLG(_D4core7runtime18runModuleUnitTestsUZ19unittestSegvHandlerUNbiPSQCk3sys5posix6signal9siginfo_tPvZv+0x38)[0x55d9bba94a40]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13150)[0x7f970a253150]
/tmp/dmd_run2hTpLG(_D9onlineapp17__unittest_L14_C1FZv+0x3a)[0x55d9bba8fe6e]
/tmp/dmd_run2hTpLG(_D9onlineapp9__modtestFZv+0x9)[0x55d9bba8fe81]
/tmp/dmd_run2hTpLG(_D4core7runtime18runModuleUnitTestsUZ14__foreachbody2MFPS6object10ModuleInfoZi+0x38)[0x55d9bba94a94]
/tmp/dmd_run2hTpLG(_D6object10ModuleInfo7opApplyFMDFPSQBhQBdZiZ9__lambda2MFyPSQCfQCbZi+0x23)[0x55d9bba9098f]
/tmp/dmd_run2hTpLG(_D2rt5minfo17moduleinfos_applyFMDFyPS6object10ModuleInfoZiZ14__foreachbody2MFKSQCz19sections_elf_shared3DSOZi+0x56)[0x55d9bba921ae]
/tmp/dmd_run2hTpLG(_D2rt19sections_elf_shared3DSO7opApplyFMDFKSQBqQBqQyZiZi+0x45)[0x55d9bba9223d]
/tmp/dmd_run2hTpLG(_D2rt5minfo17moduleinfos_applyFMDFyPS6object10ModuleInfoZiZi+0x22)[0x55d9bba9213a]
/tmp/dmd_run2hTpLG(_D6object10ModuleInfo7opApplyFMDFPSQBhQBdZiZi+0x22)[0x55d9bba90966]
/tmp/dmd_run2hTpLG(runModuleUnitTests+0x13e)[0x55d9bba9486a]
/tmp/dmd_run2hTpLG(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv+0x25)[0x55d9bba90f31]
/tmp/dmd_run2hTpLG(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv+0x20)[0x55d9bba90eb8]
/tmp/dmd_run2hTpLG(_d_run_main+0x1cf)[0x55d9bba90e23]
/tmp/dmd_run2hTpLG(main+0x22)[0x55d9bba8fea6]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f9709a621c1]
/tmp/dmd_run2hTpLG(_start+0x2a)[0x55d9bba8fd4a]
Error: program killed by signal 11



More information about the Digitalmars-d-learn mailing list