diff --git a/src/items/external-blocks.md b/src/items/external-blocks.md index 5e63e7eab..3bed8aaf2 100644 --- a/src/items/external-blocks.md +++ b/src/items/external-blocks.md @@ -179,9 +179,15 @@ unsafe extern "C" { unsafe fn foo(...); unsafe fn bar(x: i32, ...); unsafe fn with_name(format: *const u8, args: ...); + // SAFETY: This function guarantees it will not access + // variadic arguments. + safe fn ignores_variadic_arguments(x: i32, ...); } ``` +> [!WARNING] +> The `safe` qualifier should not be used on a function in an `extern` block unless that function guarantees that it will not access the variadic arguments at all. Passing an unexpected number of arguments or arguments of unexpected type to a variadic function may lead to [undefined behavior][undefined]. + r[items.extern.attributes] ## Attributes on extern blocks