1213
you are viewing a single comment's thread
view the rest of the comments
[-] calcopiritus@lemmy.world 1 points 2 hours ago

I recently came across a rust book on how pointers aren't just ints, because of UB.

fn main() {
    a = &1
    b = &2
    a++
    if a == b {
        *a = 3
        print(b)
    }
}

This may either: not print anything, print 3 or print 2.

Depending on the compiler, since b isn't changed at all, it might optimize the print for print(2) instead of print(b). Even though everyone can agree that it should either not print anything or 3, but never 2.

this post was submitted on 17 Oct 2024
1213 points (99.0% liked)

RetroGaming

19341 readers
1260 users here now

Vintage gaming community.

Rules:

  1. Be kind.
  2. No spam or soliciting for money.
  3. No racism or other bigotry allowed.
  4. Obviously nothing illegal.

If you see these please report them.

founded 1 year ago
MODERATORS