ldc-developers/ldc — Issue #85: ICE with a non-POD local struct literal in a class method
Author: SiegeLord
Created: 2012-02-24 23:58:50+00:00
State: open

```d
class Test // test() must be in a class
{
void test()
{
struct Struct
{
void test2() // struct must have a method
{

}
}
auto s = Struct(); // ICE happens once a literal is declared
}
}

```

Error:

```
ldc2: /home/siege/src/ldc/gen/llvmhelpers.cpp:482: void DtoAssign(Loc&, DValue*, DValue*, int): Assertion `t2->ty == Tclass' failed.
0 ldc2 0x0000000000fecc4f
1 ldc2 0x0000000000fed159
2 libpthread.so.0 0x00007fb0e52a2060
3 libc.so.6 0x00007fb0e436f3a5 gsignal + 53
4 libc.so.6 0x00007fb0e4372b0b abort + 379
5 libc.so.6 0x00007fb0e4367d4d __assert_fail + 221
6 ldc2 0x00000000006a5689 DtoAssign(Loc&, DValue*, DValue*, int) + 2441
7 ldc2 0x00000000006ce451 StructLiteralExp::toElem(IRState*) + 609
8 ldc2 0x00000000006c3a21 AssignExp::toElem(IRState*) + 193
9 ldc2 0x00000000006a5a44 DtoDeclarationExp(Dsymbol*) + 644
10 ldc2 0x00000000006c1871 DeclarationExp::toElem(IRState*) + 65
11 ldc2 0x00000000006c17b4 Expression::toElemDtor(IRState*) + 68
12 ldc2 0x000000000068daca ExpStatement::toIR(IRState*) + 90
13 ldc2 0x000000000068d32e CompoundStatement::toIR(IRState*) + 94
Aborted
```

You can work around this by moving the struct definition outside the method.