rui314 / 9cc

A Small C Compiler
MIT License
1.83k stars 155 forks source link

FIX: core dump while lvars may use before declaration in `param_declaration #23

Closed git-hulk closed 5 years ago

git-hulk commented 5 years ago

9cc may core dump while param_declaration may use lvars before declaration

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xc)
  * frame #0: 0x000000010000c4e4 9cc`vec_push(v=0x0000000000000000, elem=0x0000000100109670) at util.c:29:10
    frame #1: 0x00000001000052ec 9cc`add_lvar(ty=0x0000000100109630, name="board") at parse.c:81:3
    frame #2: 0x0000000100007f49 9cc`param_declaration at parse.c:717:10
    frame #3: 0x0000000100004f1f 9cc`toplevel at parse.c:895:24
git-hulk commented 5 years ago

dup PR, close it