News for hackers. Stuff that matters.
Re:Zig: a system language which prioritizes optimality, safe... by dbaupp on Tuesday August 30, 2016 @04:30PM (#12393603)
A segfault on null is fine if the language defines it to be OK (i.e. dereferencing null is reliably a crash), but most environments that allow interacting with null (C, C++, LLVM IR) have dereferencing it be undefined behaviour, i.e. the compiler may optimise in ways that mean code that naively results in a null dereference/segfault do not do that and instead result in random memory corruption.

Note that Nim uses C as an intermediate language for compilation, so unchecked dereferences of possibly-null pointers are not memory safe.

Re:Zig: a system language which prioritizes optimality, safe... by dom96 on Tuesday August 30, 2016 @05:52PM (#12394245)
Modifying Nim to perform a check before each dereference would be trivial. The reason this isn't done yet is because in practice unchecked dereferences do not cause random memory corruption, I have been using Nim for a while now and have never seen an instance where this was a problem.