2 ms·
Your example doesn't produce SIGSEGV for me. It prints out the text, "nil". However, if I write echo(cfg.someSetting[0]) it will segfault. This makes s
by SamReidHughes 10y ago
Your example doesn't produce SIGSEGV for me. It prints out the text, "nil".
However, if I write
echo(cfg.someSetting[0])
it will segfault. This makes sense because it dereferences a null pointer (in Nim-speak, a nil value). I would guess that's what you experienced.
Dereferencing a null pointer is not unsafe. The program cleanly exits. Compiling that via C is sketchy though, because the C compiler may treat provable null pointer dereferences as undefined behavior.