logoalt Hacker News

wat10000yesterday at 11:33 PM0 repliesview on HN

It's definitely a real issue in real code, since the CPU isn't bound by things like function boundaries or alias analysis or pointer validity. For example:

  x = *a;
  if (x) y = *b;
The compiler cannot reorder the load of b before the load of a, because it may not be a valid pointer if x is false. But the CPU is free to speculate long ahead, and if the pointer in b isn't valid, that's fine, the CPU can attempt a speculative load and fail.

It's not particularly common and code that has this issue will probably crash only rarely, but it's not too hard to do.