-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
The documentation gives an example of "correct" usage of a mutable static, where a hypothetical "atomic_add" function is called.
https://doc.rust-lang.org/reference/items/static-items.html#mutable-statics
However, AIUI this code is incorrect as soon as a mutable reference is created to the static variable, as the lack of synchronization means that the mutable reference may alias.
This means that mutable statics can only be used when you already have some method of synchronization in place. Unfortunately this makes mutable statics quite useless. For example: a typical use of a mutable static might be to store a libc::sem_t semaphore type.
Metadata
Metadata
Assignees
Labels
No labels