[SR-5046] Difficult to pass nil as CVarArg to withVaList #47622
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Additional Detail from JIRA
md5: c0f9dc163657df2f789b8f767a83856a
Issue Description:
Since the stdlib pointer types started representing null pointers as
Optional.none
, it has become difficult to pass a null pointer as a CVarArg.Here is a working example from Stack Overflow user MartinR: https://stackoverflow.com/a/32064355
Having to use
unsafeBitCast
is awkward; it would be better if a null pointer could be used directly in this context. Perhaps the right solution is something likeextension Optional: CVarArg where Wrapped == OpaquePointer/UnsafePointer/...
. (For that matter, it would also be nice to have an easier way to obtain a null OpaquePointer, perhaps something likeinit?() { return nil }
.)The text was updated successfully, but these errors were encountered: