Giving an input of just the character ? or \n will result in a segfault. For the "?" case:
Example of error:
dnabre@melchior:~/work/quich$ ./quich ? Segmentation fault (core dumped)
Quick gdb and backtrace:
`
dnabre@melchior:~/work/quich$ gdb quich
GNU gdb (GDB) (Cygwin 8.1.1-1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from quich...done.
(gdb) run
Starting program: /cygdrive/x/Users/barrick/work/quich/quich
[New Thread 20172.0x24c4]
[New Thread 20172.0x4018]
[New Thread 20172.0x3d54]
[New Thread 20172.0x39f8]
?
Thread 1 "quich" received signal SIGSEGV, Segmentation fault.
0x0000000100401ddb in calc () at src/parser.c:143
143 result = strToDouble(result_head->val);
(gdb) bt
0 0x0000000100401ddb in calc () at src/parser.c:143
1 0x00000001004010b3 in print (func=0x60003de00 "?") at src/main.c:22
2 0x00000001004014fa in read () at src/main.c:117
3 0x0000000100401536 in main (argc=1, argv=0xffffcc30) at src/main.c:128
Giving an input of just the character ? or \n will result in a segfault. For the "?" case:
Example of error:
dnabre@melchior:~/work/quich$ ./quich ? Segmentation fault (core dumped)
Quick gdb and backtrace: ` dnabre@melchior:~/work/quich$ gdb quich GNU gdb (GDB) (Cygwin 8.1.1-1) 8.1.1 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-cygwin". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from quich...done. (gdb) run Starting program: /cygdrive/x/Users/barrick/work/quich/quich [New Thread 20172.0x24c4] [New Thread 20172.0x4018] [New Thread 20172.0x3d54] [New Thread 20172.0x39f8]
Thread 1 "quich" received signal SIGSEGV, Segmentation fault. 0x0000000100401ddb in calc () at src/parser.c:143 143 result = strToDouble(result_head->val); (gdb) bt
0 0x0000000100401ddb in calc () at src/parser.c:143
1 0x00000001004010b3 in print (func=0x60003de00 "?") at src/main.c:22
2 0x00000001004014fa in read () at src/main.c:117
3 0x0000000100401536 in main (argc=1, argv=0xffffcc30) at src/main.c:128
(gdb) print result_head $1 = (token_t ) 0x0 (gdb) print node $2 = (token_t ) 0x0 (gdb) `
Quick look at parser.c:143, operands_first is null and that is propograting to node and result.