Skip to content

switch @jump over an integer with empty default: case causes compiler segfault #1894

@Book-reader

Description

@Book-reader
module test;

fn void main()
{
  switch (0) @jump
  {
    case 0:
      break;
    default:
  }
}
(gdb) bt
#0  llvm_emit_stmt (c=0x55555d4dc000, ast=0x0) at ../src/compiler/llvm_codegen_stmt.c:1642
#1  0x0000555555d83a21 in llvm_emit_switch_jump_table (c=0x55555d4dc000, switch_ast=<optimized out>, default_case=<optimized out>, switch_value=<optimized out>, exit_block=0x55555d4f73c0,
    cases=<optimized out>) at ../src/compiler/llvm_codegen_stmt.c:919
#2  llvm_emit_switch_body (c=0x55555d4dc000, switch_value=<optimized out>, switch_ast=<optimized out>, is_typeid=<optimized out>) at ../src/compiler/llvm_codegen_stmt.c:1011
#3  0x0000555555d82e84 in llvm_emit_switch (c=0x55555d4dc000, ast=0x7fff35600070) at ../src/compiler/llvm_codegen_stmt.c:1076
#4  0x0000555555d7ee89 in llvm_emit_body (c=0x55555d4dc000, function=<optimized out>, prototype=0x7fff76eac060, body=<optimized out>, decl=<optimized out>, signature=<optimized out>)
    at ../src/compiler/llvm_codegen_function.c:509
#5  llvm_emit_function_body (c=0x55555d4dc000, decl=<optimized out>) at ../src/compiler/llvm_codegen_function.c:429
#6  0x0000555555d5f213 in llvm_gen_module (module=<optimized out>, shared_context=<optimized out>) at ../src/compiler/llvm_codegen.c:1663
#7  0x0000555555d5cdd8 in llvm_gen (modules=0x7fff7677c338, module_count=110) at ../src/compiler/llvm_codegen.c:1522
#8  0x0000555555cac57a in compiler_compile () at ../src/compiler/compiler.c:485
#9  0x0000555555caf55c in compile () at ../src/compiler/compiler.c:1407
#10 0x0000555555d3ff5c in main_real (argc=3, argv=0x7fffffffe358) at ../src/main.c:82
#11 0x00007ffff777fe08 in __libc_start_call_main (main=main@entry=0x555555d40020 <main>, argc=argc@entry=3, argv=argv@entry=0x7fffffffe358) at ../sysdeps/nptl/libc_start_call_main.h:58
#12 0x00007ffff777fecc in __libc_start_main_impl (main=0x555555d40020 <main>, argc=3, argv=0x7fffffffe358, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
    stack_end=0x7fffffffe348) at ../csu/libc-start.c:360
#13 0x0000555555c9c355 in _start ()

Metadata

Metadata

Assignees

Labels

Fixed needs testingNeeds verification / testing that it now works

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions