Skip to content

Commit f02d746

Browse files
folkertdevtraviscross
authored andcommitted
Add warning about the safety of extern c-variadic functions
1 parent 056d4e6 commit f02d746

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/items/external-blocks.md

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

186+
> [!WARNING]
187+
> `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].
188+
185189
r[items.extern.attributes]
186190
## Attributes on extern blocks
187191

0 commit comments

Comments
 (0)