Assembly programmer here.
Depending upon the architecture, not all values can be memory addresses (aka pointers) due to alignment constraints. Then other way around is possible as long as memory addresses have at least l the same number of bits as integers.
Finally, as long as you don't dereference an integer used (casted) as a pointer, there is no difference. Like equality comparison.
Recommended further reading in this blog series by Ralf Jung: https://www.ralfj.de/blog/2020/12/14/provenance.html
Context.
I don't think GCC is doing something special, rather that -O3 might be optimizing out the subtraction. Try with -O0, I suspect you will get the same result as clang.
2018, and some of the comments are already outdated, SPARK 2014 is out there with ownership model.
One is a mathematical construct, the other is a dog?
well, their names, for starters...
There is no difference.
Yes, I'm a C programmer, how did you know?
range of values
> First, does this C program execute undefined behavior? It does not! Computing out-of-bounds pointers is UB but we are free to do whatever we like with integer-typed values that were derived from pointers. Second, does the C standard mandate the behavior that we saw here? It does not!
Behaviour that is not defined is undefined behaviour. Integer to pointer conversion is IDB, which is the same as UB except that a conforming compiler documents what could happen. I believe it's typically documented as unpredictable, so the same as plain UB.
This is interesting
Article says pointers and its are both just bitvectors, but doesn't explain what a bitvector is.
It seems to be a vector of bits? Except in practice, a bitvector is just an int where you're using the binary digits to store stuff? And you gotta use these awkward bitwise operators to actually use it? (Popular in 90s video games, to save RAM!)
Or was it another way of saying "ultimately it's the same pattern of ones and zeroes so you can do whatever you want with it as long as you know what you're doing" ?