-
Notifications
You must be signed in to change notification settings - Fork 13.4k
C-variadic functions must be unsafe #141733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,3 +83,12 @@ trait T { | |
//~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg | ||
//~| ERROR `...` must be the last argument of a C-variadic function | ||
} | ||
|
||
unsafe extern "C" { | ||
safe fn s_f1(...); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that this is machine applicable, it would be good to have one or two examples with longer signatures containing additional arguments. A printf-style signature would be a good example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (And how did I get this far without knowing that |
||
//~^ ERROR foreign functions with a C-variadic argument cannot be safe | ||
safe fn printf(format: *const u8, ...); | ||
//~^ ERROR foreign functions with a C-variadic argument cannot be safe | ||
safe fn snprintf(s: *mut u8, n: usize, format: *const u8, ...); | ||
//~^ ERROR foreign functions with a C-variadic argument cannot be safe | ||
} |
Uh oh!
There was an error while loading. Please reload this page.