Dangling pointer example in "FFI Idioms/Passing Strings" - is it actually correct? #351
ImplOfAnImpl
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone.
I'm relatively new to Rust, so I may be missing something, but the example at the end of "FFI Idioms/Passing Strings" doesn't seem correct to me:
As I see it, assuming that
seterr
doesn't store the pointer anywhere, it won't dangle, because the scope of the corresponding temporary should be the whole statement containing the call.Btw, the example in the documentation for CString::as_ptr is slightly different; there the creation and the usage of the pointer are in different statements and the pointer is dangling indeed:
Perhaps the example in "Passing Strings" should be formulated in the same way?
Beta Was this translation helpful? Give feedback.
All reactions