20 ms·
You're either coming up with a huge strawman, or you're confused about what the post means. Pointers being integers does not mean that writing garbage to any r
by dooglius 6y ago
You're either coming up with a huge strawman, or you're confused about what the post means.
Pointers being integers does not mean that writing garbage to any random integer you come up with has well-defined semantics. In any case, your example could be made much better by pointing out that any program could simply overwrite the stack return value; that has to be UB.
> To permit this basic optimization, you need to have to some sort of rule that allows you to reason that a value whose address is never taken can never be legally accessed by a pointer
This is true
>To actually effect this rule in semantics, you now have to start tracking extra metadata about what pointers can and cannot access
If you aren't writing to random values, you don't really need to track anything. foo(bar *) doesn't need to track anything, it's presumably part of the implicit contract that you allow foo to write to the passed in object.