← Back to context

Comment by ptx

3 years ago

Hmm. So the claim article was examining here was "no undefined values", and you point out that the value is actually initialized to 0 and is thus not undefined.

However, the vlang.io page also makes the separate claim (as mentioned in the article) of "no null". But you seem to be saying that the bug in this case was actually a null pointer?

Yes, it is a null pointer, produced by the initialization to 0, as you noticed.

That is the current state - V wants to prevent setting pointers to arbitrary values, including 0, outside of unsafe code, but not all cases are checked yet, and you can get one. For example, you can also still cast numbers to pointers without unsafe{}:

    x := voidptr(0)
    println(x)

... and that will compile without an error, and produce `0x0`.

You can also search the issues, and find other examples of code, that ultimately produced null pointers.