bcc
bcc copied to clipboard
Pointer casting
- Pointers are not implicity convertible to number types in vanilla. For compatibility with vanilla, and also for safety reasons (accidental pointer to Int conversions etc.), NG should behave the same way. For instance, vanilla does not allow this:
Local a:Double
Local p:Int = Varptr a ' cast needs to be explicit: "= Int Varptr a"
- Vanilla also does not implicitly convert between different pointer types, for example from Double Ptr to Int Ptr. An exception to this is the Byte Ptr, which every pointer type (plus any object and function type) has an implicit conversion to.
- NG currently allows casting pointers to String (which produces invalid C code). In vanilla, this kind of cast is neither implicitly nor explicitly allowed; converting a pointer to a String requires explicit casting to an integer type first.
- Currently it is not possible to cast Struct pointers to any other type. They should behave like other pointers and be implicitl convertible to Byte Ptr and explicitly to any other pointer type as well as to any integral type.
- Casting pointers to intrinsic types such as Int128 causes an "Internal Error" in bcc. Doing that makes little sense, so it probably shouldn't be allowed, but it should produce a proper error message.