Compiler crash when returning alias this'd type.
my (WIP) nulib package contains a nogc alternative to D GC'ed strings. This type is alias-this'd into its corrosponding D string type (since under the hood they're both immutable(T)[] slices).
The nulib type
enum isSomeChar(T) =
is(T : char) || is(T : wchar) || is(T : dchar);
alias nstring = StringImpl!char;
struct StringImpl(T) if (isSomeChar!T) {
@nogc:
private:
// Backing slice of the string.
immutable(T)[] memory;
public:
alias value this;
/**
Gets the internal memory slice.
*/
@property immutable(T)[] value() inout @trusted nothrow pure => memory;
}
import nulib;
/**
Interface to Windows PE Images.
*/
class PEImage {
// Base Info
nstring fileName_;
string name() => fileName_;
}
The crash in question
Function return type does not match operand type of return inst!
ret ptr %3, !dbg !351
{ i64, ptr }LLVM ERROR: Broken module found, compilation aborted!
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 ldc2 0x00005631aee520e7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1 ldc2 0x00005631aee4feec llvm::sys::RunSignalHandlers() + 188
2 ldc2 0x00005631aee5278f
3 libc.so.6 0x00007f7b4a445520
4 libc.so.6 0x00007f7b4a4999fc pthread_kill + 300
5 libc.so.6 0x00007f7b4a445476 raise + 22
6 libc.so.6 0x00007f7b4a42b7f3 abort + 211
7 ldc2 0x00005631aedbde09 llvm::report_fatal_error(llvm::Twine const&, bool) + 441
8 ldc2 0x00005631aedbdc46
9 ldc2 0x00005631aec2e74c
10 ldc2 0x00005631af1352cd
11 ldc2 0x00005631aec0295d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 493
12 ldc2 0x00005631af12fcc7 runOptimizationPasses(llvm::Module*) + 5831
13 ldc2 0x00005631af1c193e writeModule(llvm::Module*, char const*) + 542
14 ldc2 0x00005631af1c09fa ldc::CodeGenerator::writeAndFreeLLModule(char const*) + 970
15 ldc2 0x00005631ab989590 codegenModules(Array<Module*>&) + 2528
16 ldc2 0x00005631ab98c865 mars_tryMain(Param&, Array<char const*>&) + 2069
17 ldc2 0x00005631ab9d9bc0 cppmain() + 9376
18 ldc2 0x00005631af37daed _D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv + 77
19 ldc2 0x00005631af37d8c4 _d_run_main2 + 468
20 ldc2 0x00005631af37d6dd _d_run_main + 141
21 ldc2 0x00005631af1bdfc8 main + 680
22 libc.so.6 0x00007f7b4a42cd90
23 libc.so.6 0x00007f7b4a42ce40 __libc_start_main + 128
24 ldc2 0x00005631ab9de78e _start + 46
Error /opt/SDKs/ldc2/bin/ldc2 failed with exit code -6.
LDC Version
ldc2 -v
binary /opt/SDKs/ldc2/bin/ldc2
version 1.40.0 (DMD v2.110.0, LLVM 19.1.3)
config /opt/SDKs/ldc2/etc/ldc2.conf (x86_64-unknown-linux-gnu)
Specifically the fact that it's alias this'd to a function which returns the private member seems to be the culprit; it tries to return the function pointer instead of the return value of the function.
This compiles fine for me with v1.40.0 on Linux x86_64 - when compiling each module separately, and both at once. So please specify the cmdline that crashes.
This compiles fine for me with v1.40.0 on Linux x86_64 - when compiling each module separately, and both at once. So please specify the cmdline that crashes.
I simplified the nulib module, so maybe a more full implementation may uncover the issue; you can dub add-local the repo in question https://github.com/inochi2D/nulib
Since there's some extra copy constructors and such involved in the full implementation.
As for the command it's just dub build --compiler=ldc2