News for hackers. Stuff that matters.
Re:Pointers Are Complicated, or What’s in a Byte? by dbaupp on Wednesday July 25, 2018 @08:44AM (#17608796)
How exactly does the model specify which loads/stores are okay to be ignored or reordered (etc.)? I feel like anything that gets close to the essence of the C/C++/Rust model (such as allowing the optimization in my example above), ends up with something pretty similar to the "allocation id" idea.

As a specific example, consider the difference between these two versions of my example above:

  int f() {
    int i = 0;
    *(&i) = 10;
    return i;
  }
and the original:

  int g(int *p) {
    int i = 0;
    *p = 10;
    return i;
  }
If a call like g(rand()) ends up with p == &i, the unoptimized versions of that and of an f() call execute exactly the same sequence of memory accesses, and yet the optimization I mention above only applies to g. In essence, the source of the number "&i" seems to matter.

> others are performed only if the pointer is specified via keywords and other annotations to have a very special meaning.

Some of this already exists, such as 'restrict'.

There are no comments on this comment yet.