Skip to content

Commit 3bd778f

Browse files
committed
add a warning about the safety of extern c-variadic functions
1 parent 056d4e6 commit 3bd778f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/items/external-blocks.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,14 @@ unsafe extern "C" {
179179
unsafe fn foo(...);
180180
unsafe fn bar(x: i32, ...);
181181
unsafe fn with_name(format: *const u8, args: ...);
182+
183+
safe fn ignores_variadic_arguments(x: i32, ...);
182184
}
183185
```
184186

187+
> [!WARNING]
188+
> `safe` should only be used in cases where the function does not look at the variadic arguments at all. Passing an unexpected number of arguments or arguments of an unexpected type to a variadic function is [undefined behavior][undefined].
189+
185190
r[items.extern.attributes]
186191
## Attributes on extern blocks
187192

0 commit comments

Comments
 (0)