You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code runs fine with rdmd and gdc, but with ldc2 it generates a segfault after the first printline:
importstd.stdio;
interfaceA {}
classB : A {
ubyte[0] test;
}
voidmain() {
A a = new B();
writeln("Got new B!");
B b = cast(B) a;
writeln("all good!");
}
Simply compile this program with ldc2, run it and you get the segfault. I used the prebuilt 0.15.1 binary on Ubuntu 14.10 x86_64. After I changed the length of the ubyte array to 1 it runs fine.
The text was updated successfully, but these errors were encountered:
For ubyte[1], a snippet from the outputted LLVM IR:
%test.B_init = type { %test.B.__vtbl*, i8*, [1 x i8], { %object.Interface* }* }
%test.B = type { %test.B.__vtbl*, i8*, [1 x i8], { %object.Interface* }* }
and for ubyte[0]:
%test.B_init = type { %test.B.__vtbl*, i8*, [0 x i8]*, { %object.Interface* }* }
%test.B = type { %test.B.__vtbl*, i8*, { %object.Interface* }* }
In the case of a zero-length array, no space should be allocated. The LLVM struct type of B is correctly generated, but the initializer is not correct. The bug is fixed by skipping zero-size fields when generating the class initializer (in IrAggr::addFieldInitializers()). Submitting a PR soon.
Thanks for this bug report! I am very new to LDC, and it was a fun bug to fix, just at the right level of difficulty for me without knowledge of LDC's codebase :))
The following code runs fine with rdmd and gdc, but with ldc2 it generates a segfault after the first printline:
Simply compile this program with ldc2, run it and you get the segfault. I used the prebuilt 0.15.1 binary on Ubuntu 14.10 x86_64. After I changed the length of the ubyte array to 1 it runs fine.
The text was updated successfully, but these errors were encountered: