News for hackers. Stuff that matters.
Re:GCC Rust Monthly Report #9 August 2021 by steveklabnik on Tuesday August 31, 2021 @10:55AM (#28368869)
> Rust needs a way to opt-out of these aggressive optimizations

As the next sentence of that very first post said:

> There is a way to tell the language exactly what you want: you can use unsafe, raw pointers, UnsafeCell, and abstractions built atop them.

And again, this is not about optimization, this is about semantics. What you want is a different semantics, which is why it is not something that we would accept as a flag. Rustc does already let you change what optimizations are done to your code (trivially: -C opt-level=n). That is not an issue. This just isn't about optimization.

Re:GCC Rust Monthly Report #9 August 2021 by Subsentient on Tuesday August 31, 2021 @11:06AM (#28369040)
Yes, it is about optimization. By your own admission, rustc allows you to set -C opt-level, and that would probably change semantics to the desired, but at significantly worse performance.

You don't seem to understand the concept of undefined behavior. What I'm trying to say is that even if rustc generates the correct output, the code could still officially be declared UB, just as it is now in debug mode. If it breaks logic that relies on the exclusivity of &mut, well, that's what UB does, it breaks things.

It is entirely an optimization option.

You're right that I think it would be nice if you could have multiple &muts created from raw pointers, but I'm not asking for that. The reason these things are issues at all is because Rust uses these references for things like RAII (e.g. &mut self in drop()), and there's no way to use raw pointers instead. If Rust provided a way to use raw pointers more easily in the places you need them, this would be a non-issue. But right now, the unsafe/safe boundary is very dangerous in Rust, so dangerous that I'm uncomfortable working in it even though I've worked in C and C++ for over a decade, and it's entirely a self-inflicted wound by the Rust devs.

Re:GCC Rust Monthly Report #9 August 2021 by steveklabnik on Tuesday August 31, 2021 @11:15AM (#28369137)
> You don't seem to understand the concept of undefined behavior

Okay, now I am done here, like you said you were before this post.

Re:GCC Rust Monthly Report #9 August 2021 by Subsentient on Tuesday August 31, 2021 @11:22AM (#28369204)
Sorry, I was getting a bit frustrated, because I kept repeating my position, and you kept saying it affected semantics, whereas if it's UB either way, it hasn't really affecting semantics officially. Yeah I'm done too. I don't enjoy arguing, and Rust in particular never brings out the best in me.
Re:GCC Rust Monthly Report #9 August 2021 by nickitolas on Tuesday August 31, 2021 @08:15PM (#28375169)
I just found this issue in gccrs about strict aliasing, you might have some valuable input for it. https://github.com/Rust-GCC/gccrs/issues/653