Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault on: "void f(int n) {}" #16

Open
Ace17 opened this issue Dec 20, 2018 · 0 comments
Open

segfault on: "void f(int n) {}" #16

Ace17 opened this issue Dec 20, 2018 · 0 comments

Comments

@Ace17
Copy link

Ace17 commented Dec 20, 2018

// yo.c
void f(int n) {}

Compilation:

$ ./9cc yo.c
[1]    27537 segmentation fault  ./9cc yo.c

Backtrace:

$ gdb --args ./9cc yo.c
Reading symbols from ./9cc...done.
(gdb) run
Starting program: /tmp/9cc/9cc yo.c

Program received signal SIGSEGV, Segmentation fault.
0x000055555555e5ab in vec_push (v=0x0, elem=0x55555556a990) at util.c:29
29        if (v->len == v->capacity) {
(gdb) bt
#0  0x000055555555e5ab in vec_push (v=0x0, elem=0x55555556a990) at util.c:29
#1  0x000055555555b728 in add_lvar (ty=0x55555556a7d0, name=0x555555569a80 "n") at parse.c:81
#2  0x000055555555d827 in param_declaration () at parse.c:717
#3  0x000055555555e0df in toplevel () at parse.c:895
#4  0x000055555555e3b5 in parse (tokens_=0x555555569fa0) at parse.c:961
#5  0x000055555555b4c4 in main (argc=2, argv=0x7fffffffe688) at main.c:34
(gdb) 
@Ace17 Ace17 changed the title segfault on: "void f(int n) { int tab[n]; }" segfault on: "void f(int n) {}" Dec 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant