-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
There is no lang item that makes +
an unsafe operation
#24326
Comments
Hm, I'm confused; where is this |
It doesn't exist in the standard library that comes with the distribution. |
Of course it does not. Carelessly using pointer arithmetic can invoke UB very easily. That's why we put it behind |
ptr.offset(1);
ptr + 1; Wow, |
@mahkoh this style of conversation is unproductive, and you know it violates community norms. Your constant search for ways to express yourself that antagonize the community wastes a lot of everyone's time. if this bug is "we need a variant of the If this bug is "i would like But it is not clear what is actionable today to address this issue. Especially since it is quite unclear what the actual issue is. |
You seem to have missed the title of the issue: There is no lang item that makes What exactly is unclear about that?
Mozilla's standard library is completely irrelevant when it comes to lang items that are a feature of the language. |
Surely by rust's logic, pointer arithmetic is not unsafe, for the same reason that converting a reference to a pointer is not unsafe: it's only unsafe to actually dereference such a pointer? Regardless, it seems quite plausible that there might be other cases where addition/other operator should be unsafe, but the "more flexible operator overloading" rfc would fix that. |
Invalid pointer arithmetic is LLVM UB - if you do it, LLVM will "miscompile" your code. Rust is meant to be used with Anyway, adding a lang-item that makes |
The core team won't enforce the code of conduct on our GitHub threads. Rather the "norm" that's been established is infinite excuses and "last" chances for this kind behavior. mahkoh has been at it for at least 5 months (I can provide specific links) and strcat was tolerated for several years. Don't be surprised when you start to lose more contributors over breaking the promise the CoC represents. I won't be the last one. |
It's unsafe because rustc uses the LLVM inbounds attribute and LLVM says that invalid pointer arithmetic with this attribute is UB even if the pointer is never used afterwards. Edit: I guess this only applies if you use the offset intrinsic but the offset intrinsic supposedly enables more optimizations compared to
I'm using it without libcore. |
Well, strcat's objections at least were smart. Providing your own libcore isn't supported. |
Could someone close this? |
@arielb1 It was my pleasure. |
If this repo cannot even be used for language only topics that are unrelated to the garbage that is the rest of the distribution then it's pretty useless. That is very good to know! |
relies on the user knowing about the unsafety.
The text was updated successfully, but these errors were encountered: