ldc
ldc copied to clipboard
postfix `++` on bitfield segfaults the compiler
$ ldc2 --version
LDC - the LLVM D compiler (1.40.0):
based on DMD v2.110.0 and LLVM 19.1.3
built with LDC - the LLVM D compiler (1.39.0)
Default target: arm64-apple-darwin23.6.0
Host CPU: apple-m1
http://dlang.org - http://wiki.dlang.org/LDC
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_32 - AArch64 (little endian ILP32)
aarch64_be - AArch64 (big endian)
amdgcn - AMD GCN GPUs
arm - ARM
arm64 - ARM64 (little endian)
arm64_32 - ARM64 (little endian ILP32)
armeb - ARM (big endian)
avr - Atmel AVR Microcontroller
bpf - BPF (host endian)
bpfeb - BPF (big endian)
bpfel - BPF (little endian)
hexagon - Hexagon
lanai - Lanai
loongarch32 - 32-bit LoongArch
loongarch64 - 64-bit LoongArch
mips - MIPS (32-bit big endian)
mips64 - MIPS (64-bit big endian)
mips64el - MIPS (64-bit little endian)
mipsel - MIPS (32-bit little endian)
msp430 - MSP430 [experimental]
nvptx - NVIDIA PTX 32-bit
nvptx64 - NVIDIA PTX 64-bit
ppc32 - PowerPC 32
ppc32le - PowerPC 32 LE
ppc64 - PowerPC 64
ppc64le - PowerPC 64 LE
r600 - AMD GPUs HD2XXX-HD6XXX
riscv32 - 32-bit RISC-V
riscv64 - 64-bit RISC-V
sparc - Sparc
sparcel - Sparc LE
sparcv9 - Sparc V9
spirv - SPIR-V Logical
spirv32 - SPIR-V 32-bit
spirv64 - SPIR-V 64-bit
systemz - SystemZ
thumb - Thumb
thumbeb - Thumb (big endian)
ve - VE
wasm32 - WebAssembly 32-bit
wasm64 - WebAssembly 64-bit
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
xcore - XCore
xtensa - Xtensa 32
Compiling this C file causes a segfault:
// repro.c
void foo(void){
struct Foo {
unsigned count:31;
};
struct Foo f = {0};
f.count++;
}
Compiler output:
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 0x0000000105449f4c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 ldc2 0x0000000105448170 llvm::sys::RunSignalHandlers() + 64
2 ldc2 0x000000010544a5a8 SignalHandler(int) + 292
3 libsystem_platform.dylib 0x0000000181426584 _sigtramp + 56
4 ldc2 0x0000000105829bcc ToElemVisitor::visit(PostExp*) + 372
5 ldc2 0x0000000105819be4 ToIRVisitor::visit(ExpStatement*) + 448
6 ldc2 0x0000000105819dfc ToIRVisitor::visit(CompoundStatement*) + 308
7 ldc2 0x0000000105819dfc ToIRVisitor::visit(CompoundStatement*) + 308
8 ldc2 0x00000001057d86d8 DtoDefineFunction(FuncDeclaration*, bool) + 5988
9 ldc2 0x00000001057c7870 CodegenVisitor::visit(AttribDeclaration*) + 80
10 ldc2 0x00000001057e8f48 codegenModule(IRState*, Module*) + 3140
11 ldc2 0x000000010586117c ldc::CodeGenerator::emit(Module*) + 216
12 ldc2 0x000000010587aa78 codegenModules(Array<Module*>&) + 976
13 ldc2 0x000000010578b424 mars_tryMain(Param&, Array<char const*>&) + 1528
14 ldc2 0x0000000105a0efbc _D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv + 116
15 ldc2 0x0000000105a0eae0 _d_run_main + 144
16 ldc2 0x0000000105877c0c main + 744
17 dyld 0x000000018106b154 start + 2476