Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Ticket #372 (new defect)

Opened 2 years ago

Last modified 1 year ago

base classes with inner classes can't be instantiated in inherited classes

Reported by: wilkie Assigned to: ChristianK
Priority: major Milestone:
Component: unspecified Version: hg tip
Keywords: Cc:

Description

long winded title, but basically this breaks LDC as of the date of this ticket. (and not DMD)

class A {
    class B {
    }
}

class C : A {
	void test () {
		B foo = new B();
	}
}

int main () {
	return 0;
}

With the assert:

ldc: /home/wilkie/llvm-2.6/lib/VMCore/Instructions.cpp:928: void 
llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast<PointerType>
(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val 
type!"' failed.
0   ldc             0x0000000000dffcbf
1   ldc             0x0000000000e0195d
2   libpthread.so.0 0x00002ab438fb1790
3   libc.so.6       0x00002ab439db1f15 gsignal + 53
4   libc.so.6       0x00002ab439db3340 abort + 384
5   libc.so.6       0x00002ab439daaf9a __assert_fail + 234
6   ldc             0x0000000000d69ca1 llvm::StoreInst::AssertOK() + 145
7   ldc             0x000000000064d020 DtoStore(llvm::Value*, llvm::Value*) + 112
8   ldc             0x0000000000666b5b DtoNewClass(Loc, TypeClass*, NewExp*) + 443
9   ldc             0x000000000066aa00 NewExp::toElem(IRState*) + 912
10  ldc             0x000000000066c051 AssignExp::toElem(IRState*) + 193
11  ldc             0x000000000067ea8c ExpStatement::toIR(IRState*) + 108
12  ldc             0x000000000067e987 CompoundStatement::toIR(IRState*) + 103
13  ldc             0x000000000067e987 CompoundStatement::toIR(IRState*) + 103
14  ldc             0x00000000006275cf DtoDefineFunction(FuncDeclaration*) + 2639
15  ldc             0x0000000000692099 Ir::emitFunctionBodies() + 57
16  ldc             0x0000000000663890 Module::genLLVMModule(llvm::LLVMContext&, Ir*) + 768
17  ldc             0x0000000000653045 main + 6229
18  libc.so.6       0x00002ab439d9e9ed __libc_start_main + 253
19  ldc             0x000000000056e2d9
Aborted

The workaround is to declare the inner class as static:

class A {
    static class B {
    }
}

Thanks!

-- wilkie

Change History

01/04/11 17:36:37 changed by mwarning

Current error from ldc:

testcase.d: Error: module testcase Stored value type does not match pointer operand type!
  store %testcase.C* %7, %object.Object** %tmp3
 %object.Object*Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Broken module found, compilation terminated.
Copyright © 2008, LDC Development Team.