Skip to content
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

Fix &mut invalidation in ptr::swap doctest #95617

Merged
merged 1 commit into from
Apr 3, 2022

Commits on Apr 3, 2022

  1. Fix &mut invalidation in ptr::swap doctest

    Under Stacked Borrows with raw pointer tagging, the previous code was UB
    because the code which creates the the second pointer borrows the array
    through a tag in the borrow stacks below the Unique tag that our first
    pointer is based on, thus invalidating the first pointer.
    
    This is not definitely a bug and may never be real UB, but I desperately
    want people to write code that conforms to SB with raw pointer tagging
    so that I can write good diagnostics. The alternative aliasing models
    aren't possible to diagnose well due to state space explosion.
    Therefore, it would be super cool if the standard library nudged people
    towards writing code that is valid with respect to SB with raw pointer
    tagging.
    saethlin committed Apr 3, 2022
    Configuration menu
    Copy the full SHA
    f4a7ed4 View commit details
    Browse the repository at this point in the history