-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Can put non-Sync data in extern statics #40652
Comments
As a result of #35112, extern statics currently require unsafe to access so this isn't a safety hole. Also, extern statics are often used to reference raw pointers which are definitely In my opinion this is working as intended. |
I agree.
There's a pattern for such thing: pub struct NotSyncAtAll<T>(*mut T);
unsafe impl<T> Sync for NotSyncAtAll<T> {}
extern "C" {
static FOO: NotSyncAtAll<u8>;
} But if
Well, that's one reason to leave things as they are. |
I'm also inclined to think this is working as intended. |
Agree that the change doesn't seem like it would buy anything and it would just result in breakage so closing. |
This is not allowed:
But this is allowed:
Using
extern "C"
doesn't suddenly makeFOO
safe to share accross threads so this should become an error, IMO. Just like #35112.cc @nikomatsakis
The text was updated successfully, but these errors were encountered: