-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Description
Some builtin functions can cause undefined behavior or subvert the Zig type system.
I think these builtin functions should be clearly marked.
Here is a list, probably incomplete:
-
@addrSpaceCast
The documentation says that the operation may be illegal. What is the difference from undefined behavior?
There is no documentation in the "Undefined Behavior" section. -
@ptrCast
The documentation says:
"Casting an optional pointer which is null to a non-optional pointer invokes safety-checked Undefined Behavior".
An additional warning is in the "volatile" section:
"To convert one pointer type to another, use@ptrCast. This is an unsafe operation that Zig cannot protect you against."
This is also documented in the "Undefined Behavior" section. -
@alignCast
Incorrect alignment is also documented in "Undefined Behavior" section. -
@qualCast
Warning about unsafe behavior is missing.
Undefined behavior caused by@qualCastshould probably be added to the "Undefined Behavior".