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

Ticket #253 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

Assertion `ts->sym->ir.irStruct->constInit' failed.

Reported by: mrmonday Assigned to: lindquist
Priority: major Milestone:
Component: backend Version: hg tip
Keywords: Cc:

Description

The following code fails to compile on linux x86_64:

struct Value {
    enum Type : ubyte {
        String,
        Int,
        Float,
        Bool,
        Block
    }
    union {
        char[] String;
        int Int;
        float Float;
        bool Bool;
        PropAssign[] Block;
    }
    Type type;
    template TypeT(T) {
        static if( is( T == char[] ) ) const Type TypeT = Type.String;
        else static if( is( T == int ) ) const Type TypeT = Type.Int;
        else static if( is( T == float ) ) const Type TypeT = Type.Float;
        else static if( is( T == bool ) ) const Type TypeT = Type.Bool;
        else static if( is( T == PropAssign[] ) ) const TypeT = Type.Block;
        else static assert( false );
    }
    static Value opCall( char[] v ) {
        Value result = void;
        result.type = Type.String;
        result.String = v;
        return result;
    }
    static Value opCall( int v ) {
        Value result = void;
        result.type = Type.Int;
        result.Int = v;
        return result;
    }
    static Value opCall( float v ) {
        Value result = void;
        result.type = Type.Float;
        result.Float = v;
        return result;
    }
    static Value opCall( bool v ) {
        Value result = void;
        result.type = Type.Bool;
        result.Bool = v;
        return result;
    }
    static Value opCall( PropAssign[] v ) {
        Value result = void;
        result.type = Type.Block;
        result.Block = v;
        return result;
    }

}
struct PropAssign {
    char[]    name;
    Value    value;
}

with the assertion:

ldc: /home/robert/d/comp/ldc/gen/toir.cpp:244: virtual llvm::Constant* VarExp::toConstElem(IRState*): Assertion `ts->sym->ir.irStruct->constInit' failed.
0   ldc       0x0000000000ce6ec1
1   libc.so.6 0x00007ff755797150
2   libc.so.6 0x00007ff7557970c5 gsignal + 53
3   libc.so.6 0x00007ff7557985e3 abort + 387
4   libc.so.6 0x00007ff7557900e9 __assert_fail + 233
5   ldc       0x00000000006517fc VarExp::toConstElem(IRState*) + 588
6   ldc       0x000000000066f44c IrStruct::buildDefaultConstInit(std::vector<llvm::Constant*, std::allocator<llvm::Constant*> >&) + 908
7   ldc       0x000000000066f5e4 IrStruct::buildDefaultConstInit() + 68
8   ldc       0x00000000006404a8
9   ldc       0x0000000000640349
10  ldc       0x0000000000640045 DtoResolveStruct(StructDeclaration*) + 1013
11  ldc       0x0000000000653b75 DtoType(Type*) + 357
12  ldc       0x00000000005dffbf DtoArrayType(Type*) + 15
13  ldc       0x0000000000653ab8 DtoType(Type*) + 168
14  ldc       0x000000000066eec4 IrStruct::addVar(VarDeclaration*) + 68
15  ldc       0x0000000000612087 VarDeclaration::codegen(Ir*) + 263
16  ldc       0x0000000000611bb1 AnonDeclaration::codegen(Ir*) + 113
17  ldc       0x000000000063fe99 DtoResolveStruct(StructDeclaration*) + 585
18  ldc       0x000000000065d669 Module::genLLVMModule(Ir*) + 617
19  ldc       0x0000000000626003 main + 4643
20  libc.so.6 0x00007ff755783546 __libc_start_main + 230
21  ldc       0x0000000000544e79

LDC Version:

LLVM D Compiler rev. 1179:71479f6e2a01 (2009-03-30 16:34 +0200)
based on DMD v1.041 and llvm 2.5 (2009-03-03 04:36:03 +0000)

-vv output: (see attached) Removing the first 4 types and just leaving PropAssign?[] results in a different assertion:

ldc: /home/robert/d/comp/llvm-2.5-src/lib/Target/TargetData.cpp:421: uint64_t llvm::TargetData::getTypeSizeInBits(const llvm::Type*) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed.
0   ldc       0x0000000000ce6ec1
1   libc.so.6 0x00007f2b3b5a6150
2   libc.so.6 0x00007f2b3b5a60c5 gsignal + 53
3   libc.so.6 0x00007f2b3b5a75e3 abort + 387
4   libc.so.6 0x00007f2b3b59f0e9 __assert_fail + 233
5   ldc       0x0000000000bf091e llvm::TargetData::getTypeSizeInBits(llvm::Type const*) const + 142
6   ldc       0x0000000000653253 getTypeStoreSize(llvm::Type const*) + 19
7   ldc       0x000000000065f3e1 TypeInfoStructDeclaration::llvmDefine() + 465
8   ldc       0x000000000065e45a DtoConstInitTypeInfo(TypeInfoDeclaration*) + 58
9   ldc       0x000000000065ec48 DtoDeclareTypeInfo(TypeInfoDeclaration*) + 344
10  ldc       0x000000000065edc9 DtoResolveTypeInfo(TypeInfoDeclaration*) + 201
11  ldc       0x000000000065e954 Type::getTypeInfo(Scope*) + 244
12  ldc       0x000000000061d7fa DtoTypeInfoOf(Type*, bool) + 26
13  ldc       0x000000000064070c
14  ldc       0x0000000000640349
15  ldc       0x0000000000640045 DtoResolveStruct(StructDeclaration*) + 1013
16  ldc       0x0000000000653b75 DtoType(Type*) + 357
17  ldc       0x00000000005dffbf DtoArrayType(Type*) + 15
18  ldc       0x0000000000653ab8 DtoType(Type*) + 168
19  ldc       0x000000000066eec4 IrStruct::addVar(VarDeclaration*) + 68
20  ldc       0x0000000000612087 VarDeclaration::codegen(Ir*) + 263
21  ldc       0x0000000000611bb1 AnonDeclaration::codegen(Ir*) + 113
22  ldc       0x000000000063fe99 DtoResolveStruct(StructDeclaration*) + 585
23  ldc       0x000000000065d669 Module::genLLVMModule(Ir*) + 617
24  ldc       0x0000000000626003 main + 4643
25  libc.so.6 0x00007f2b3b592546 __libc_start_main + 230
26  ldc       0x0000000000544e79

These assertions are currently preventing hybrid from compiling (there are others too).

Attachments

253-vv.txt (19.2 kB) - added by mrmonday on 04/01/09 16:40:54.
-vv Output for ticket #253

Change History

04/01/09 16:40:54 changed by mrmonday

  • attachment 253-vv.txt added.

-vv Output for ticket #253

(follow-up: ↓ 2 ) 04/02/09 15:36:32 changed by ChristianK

  • owner changed from ChristianK to lindquist.
  • component changed from unspecified to backend.

Severely reduced, that test case asserts:

TargetData.cpp:421: uint64_t llvm::TargetData::getTypeSizeInBits(const llvm::Type*) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed.

struct Value {
    PropAssign[] Block;
}
struct PropAssign {
    Value    value;
}

(in reply to: ↑ 1 ) 04/02/09 15:42:48 changed by mrmonday

Replying to ChristianK:

Severely reduced, that test case asserts: TargetData.cpp:421: uint64_t llvm::TargetData::getTypeSizeInBits(const llvm::Type*) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed.

This is the later assert I mentioned, not the original. This bug report essentially covers 2 assertions.

TargetData.cpp:421: uint64_t llvm::TargetData::getTypeSizeInBits(const llvm::Type*) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed.

and

gen/toir.cpp:244: virtual llvm::Constant* VarExp::toConstElem(IRState*): Assertion `ts->sym->ir.irStruct->constInit' failed.

04/04/09 21:51:12 changed by mandel

The bug starts to be triggered between ldc revisions 1169 and 1173.

04/06/09 12:53:48 changed by lindquist

  • status changed from new to assigned.

04/21/09 12:24:13 changed by lindquist

  • status changed from assigned to closed.
  • resolution set to fixed.

fixed since rev [1248]

Copyright © 2008, LDC Development Team.