Because it violates the as-if rule. The calloc call is required to fail; transformation makes it succeed.
I don't think just checking accesses is sufficient. There's also arithmetic & other considerations.
-
-
The standard doesn't mention arithmetic, but it does seem impossible to satisfy reqs for pointer subtraction.
-
Consider X=SIZE_MAX; p=calloc(X,X); if(p) printf("%p %p\n", p, p+X+1); // opt reducing alloc'd size is invalid.
-
I think you could say as long as the pointer is considered valid, it's okay ("magic compression").
-
No, there are clear violations of as-if rule (xform produces output non-xformed ver provably doesn't produce).
-
Yes, that would only be valid if it were something calloc did anyway.
-
calloc can't do that. All objects have unique addresses, all array members have unique offsets.
-
:-/ If the program never checks that, isn't it as-if it can do magic?
-
That's what I was saying - without asserting non-existence of any code that sees the diff, the xform is invalid
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.