Null pointer can be constructed and dereferenced in safe code #20497
Labels
Bug
This tag is applied to issues which reports bugs.
Unit: Checker
Bugs/feature requests, that are related to the type checker.
Unit: Type System
Bugs/feature requests, that are related to the V types system.
Describe the bug
V allows constructing and dereferencing null pointers in safe code. This results in undefined behavior using the C backend.
Reproduction Steps
Expected Behavior
&T(nil)
is already illegal, so I would expect V to give a compile time error when using&T(0)
as well.In fact, in safe code casting an arbitrary number to a pointer should probably never be allowed.
Current Behavior
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.4 ac2dcc2
Environment details (OS name and version, etc.)
NixOS 23.11 (Tapir)
gcc (GCC) 12.3.0
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: