OK, firstly, a small nitpick, you weren't getting a segfault (SIGSEGV) but a SIGABRT
As for failing to return a value from a non-void function, you should at the very least compile with -Wall, which would have caught that. e.g
/* n.c - no return from non-void function */staticinttest(void){}
$ gcc -c n.c
$
vs
$ gcc -Wall -c n.c
n.c: In function ‘test’:
n.c:5:1: warning: no return statement in function returning non-void [-Wreturn-type]
5 | }
| ^
At top level:
n.c:3:12: warning: ‘test’ defined but not used [-Wunused-function]
3 | static int test(void)
| ^~~~
$
And of course we also get the second warning...
I always compile with at least '-Wall -Wextra'
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
OK, firstly, a small nitpick, you weren't getting a segfault (SIGSEGV) but a SIGABRT
As for failing to return a value from a non-void function, you should at the very least compile with -Wall, which would have caught that. e.g
vs
And of course we also get the second warning...
I always compile with at least '-Wall -Wextra'