Bug 19031 – [REG 2.080.0] assert failure when subclassing C++ class with D class

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-06-27T15:13:21Z
Last change time
2018-12-14T10:59:56Z
Assigned to
No Owner
Creator
Jacob Carlborg

Comments

Comment #0 by doob — 2018-06-27T15:13:21Z
I don't have a reduced test case but compiling the following code results in an assertion failure: import dmd.attrib; import dmd.visitor; class Foo : SemanticTimeTransitiveVisitor { override void visit(UserAttributeDeclaration uda) { writeln("asd"); } } Compile with: dmd main.d -Isrc -version=NoBackend. This is compiling some parts of the DMD source code, currently at commit 033d324957ff5bee8e25c7335eab2c562d17e2b1.
Comment #1 by doob — 2018-06-27T15:15:22Z
Forgot to mention, this gave an compile error compiling with DMD 2.079.0 but fails with 2.080.0 and up to master, currently at 033d324957ff5bee8e25c7335eab2c562d17e2b1. The assertion failure is: DMD v2.081.0-beta.2-70-g033d32495 DEBUG --- ERROR: This is a compiler bug. Please report it via https://issues.dlang.org/enter_bug.cgi with, preferably, a reduced, reproducible example and the information below. DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction. --- DMD v2.081.0-beta.2-70-g033d32495 predefs NoBackend DigitalMars Posix OSX darwin LittleEndian D_Version2 all D_SIMD D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert D_HardFloat D_ObjectiveCbinary ./generated/osx/release/64/dmd version v2.081.0-beta.2-70-g033d32495 config ./generated/osx/release/64/dmd.conf DFLAGS -I./generated/osx/release/64/../../../../../druntime/import -I./generated/osx/release/64/../../../../../phobos -L-L./generated/osx/release/64/../../../../../phobos/generated/osx/release/64 -fPIC --- core.exception.AssertError@dmd/dsymbolsem.d(3460): Assertion failure ---------------- 4 dmd 0x000000010f718cc9 _d_assertp + 117 5 dmd 0x000000010f520172 _ZN22DsymbolSemanticVisitor23funcDeclarationSemanticEP15FuncDeclaration + 7950 6 dmd 0x000000010f520878 _ZN22DsymbolSemanticVisitor5visitEP15FuncDeclaration + 28 7 dmd 0x000000010f574b8d _ZN15FuncDeclaration6acceptEP7Visitor + 33 8 dmd 0x000000010f516c0c _Z15dsymbolSemanticP7DsymbolP5Scope + 64 9 dmd 0x000000010f5243cc _ZN22DsymbolSemanticVisitor5visitEP16ClassDeclaration + 5864 10 dmd 0x000000010f4e3855 _ZN16ClassDeclaration6acceptEP7Visitor + 33 11 dmd 0x000000010f516c0c _Z15dsymbolSemanticP7DsymbolP5Scope + 64 12 dmd 0x000000010f51bcf5 _ZN22DsymbolSemanticVisitor5visitEP6Module + 137 13 dmd 0x000000010f505f85 _ZN6Module6acceptEP7Visitor + 33 14 dmd 0x000000010f516c0c _Z15dsymbolSemanticP7DsymbolP5Scope + 64 15 dmd 0x000000010f5ad44d int dmd.mars.tryMain(ulong, const(char)**) + 6265 16 dmd 0x000000010f4b03b6 _Dmain + 38 17 dmd 0x000000010f72bb1b void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll().__lambda1() + 39 18 dmd 0x000000010f72b9ab void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) + 31 19 dmd 0x000000010f72ba86 void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() + 138 20 dmd 0x000000010f72b9ab void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) + 31 21 dmd 0x000000010f72b919 _d_run_main + 485 22 dmd 0x000000010f4b0429 main + 33 23 libdyld.dylib 0x00007fff6ac20014 start + 0 24 ??? 0x0000000000000003 0x0 + 3
Comment #2 by razvan.nitu1305 — 2018-07-04T07:50:59Z
Try making class Foo extern(C++) and add "alias visit = SemanticTimeTransitiveVisitor.visit" in the class body. This should get rid of the compile errors (don't know about the assert though).
Comment #3 by razvan.nitu1305 — 2018-12-14T10:51:17Z
Is this still valid? Compiling the original code leads to: main.d(6): Error: function void main.Foo.visit(UserAttributeDeclaration uda) does not override any function, did you mean to override alias dmd.visitor.SemanticTimeTransitiveVisitor.visit? main.d(6): Functions are the only declarations that may be overriden It was probably fixed by : https://github.com/dlang/dmd/pull/8665 Closing as fixed. Please reopen if I am missing something.
Comment #4 by doob — 2018-12-14T10:59:56Z
Seems to be fixed in 2.083.0.