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

Ticket #259 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

Assertion `0 && "default initializer type does not match the default struct type"' failed.

Reported by: mrmonday Assigned to: lindquist
Priority: major Milestone:
Component: frontend + backend Version: hg tip
Keywords: accept-invalid Cc:

Description (Last modified by ChristianK)

When compiling the following test case:

struct Vector {
        union { float x; float y; }
        const static Vector zero = { x : 0, y : 0 };
}

struct HBoxLayout {
        Vector padding  = Vector.zero;
}

I get:

ldc: /home/robert/d/comp/ldc/ir/irstruct.cpp:201: llvm::Constant* IrStruct::createStructDefaultInitializer(): Assertion `0 && "default initializer type does not match the default struct type"' failed.
0   ldc       0x0000000000cec2d1
1   libc.so.6 0x00007fdab6d95150
2   libc.so.6 0x00007fdab6d950c5 gsignal + 53
3   libc.so.6 0x00007fdab6d965e3 abort + 387
4   libc.so.6 0x00007fdab6d8e0e9 __assert_fail + 233
5   ldc       0x0000000000671fc0 IrStruct::createStructDefaultInitializer() + 944
6   ldc       0x000000000067204d IrStruct::getDefaultInit() + 61
7   ldc       0x000000000063f048 DtoResolveStruct(StructDeclaration*) + 360
8   ldc       0x000000000065df51 Module::genLLVMModule(Ir*) + 609
9   ldc       0x000000000062315b main + 4891
10  libc.so.6 0x00007fdab6d81546 __libc_start_main + 230
11  ldc       0x0000000000546d69

On linux x86-64, ldc version:

LLVM D Compiler rev. 1248:01909bd1132c (2009-04-21 17:54 +0200)
based on DMD v1.042 and llvm 2.5 (2009-03-03 04:36:03 +0000)

Change History

04/21/09 14:16:18 changed by mrmonday

The one time I don't click preview...

ldc: /home/robert/d/comp/ldc/ir/irstruct.cpp:201: llvm::Constant* IrStruct::createStructDefaultInitializer(): Assertion `0 && "default initializer type does not match the default struct type"' failed.
0   ldc       0x0000000000cec2d1
1   libc.so.6 0x00007fdab6d95150
2   libc.so.6 0x00007fdab6d950c5 gsignal + 53
3   libc.so.6 0x00007fdab6d965e3 abort + 387
4   libc.so.6 0x00007fdab6d8e0e9 __assert_fail + 233
5   ldc       0x0000000000671fc0 IrStruct::createStructDefaultInitializer() + 944
6   ldc       0x000000000067204d IrStruct::getDefaultInit() + 61
7   ldc       0x000000000063f048 DtoResolveStruct(StructDeclaration*) + 360
8   ldc       0x000000000065df51 Module::genLLVMModule(Ir*) + 609
9   ldc       0x000000000062315b main + 4891
10  libc.so.6 0x00007fdab6d81546 __libc_start_main + 230
11  ldc       0x0000000000546d69

04/21/09 14:28:57 changed by ChristianK

  • description changed.

04/21/09 18:27:59 changed by lindquist

  • keywords set to accept-invalid.
  • owner changed from ChristianK to lindquist.
  • component changed from unspecified to frontend + backend.

this is an "accept-invalid" bug, compiling should say: Error: foo.d:3 : overlapping initialization of x and y. (or something like that), I'll fix it, but I doubt this was the original problem...

one could say it's a problem in the DMD frontend, as invalid AST is reaching codegen, but DMD handles these kind of errors in the codegen phase ...

04/21/09 19:25:02 changed by lindquist

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

Since rev [1254] this is now an error. The "meaningul" code:

struct Vector {
        union { float x; float y; }
        const static Vector zero = { x : 0 };
}

struct HBoxLayout {
        Vector padding  = Vector.zero;
}

also compiles correctly into:

  %foo.HBoxLayout = type { %foo.Vector }
  %foo.Vector = type { float }

@_D3foo6Vector6__initZ = constant %foo.Vector { float 0x7FF8000000000000 }
@_D3foo6Vector4zeroS3foo6Vector = constant %foo.Vector zeroinitializer
@_D3foo10HBoxLayout6__initZ = constant %foo.HBoxLayout zeroinitializer
Copyright © 2008, LDC Development Team.