-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Flow based const qualification is unsound when combined with mut references / raw pointer deref #90124
Comments
There are some, inconveniently collapsed, comments, regarding indirect mutation and const qualification:
Looks like the final approach was to at least partially ignore the issue of indirect mutation, since mutable references were unsupported at that time. @rust-lang/wg-const-eval |
Quoting the first comment
So, I thought that had happened, but it appears we lost it. Replacing the qualif of a borrowed place with the full type's qualif seems like the most reasonable approach. We don't need to be perfect with this analysis in the presence of references and raw pointers. |
Ouch. FYI this did get implemented:
There's just a bug somewhere. I could have sworn we had a test for |
The problem in that case, is that indirect mutation data flow is completely |
Ugh, you're correct of course. How embarrassing. The problem manifests when we assign a local that has been mutated indirectly to one that has not been (in this case the "return place" of the const initializer). |
For example, the constant C is presumed not to need drop (the example can be easily adapted to other qualifs & situations):
@rustbot label +A-const-eval +A-const-fn +F-const_mut_refs
The text was updated successfully, but these errors were encountered: