p2 might actually point to the same location as p1, so you can't avoid fetching from memory the second time.
Not necessarily: if p1 and p2 are of different types (and neither is char * or void *), then the compiler is free to assume that they don't point to the same location. This is called "strict aliasing" per the C99 spec; it breaks a lot of old C code.
Not necessarily: if p1 and p2 are of different types (and neither is char * or void *), then the compiler is free to assume that they don't point to the same location. This is called "strict aliasing" per the C99 spec; it breaks a lot of old C code.
http://www.cellperformance.com/mike_acton/2006/06/understand...
But in any case, this isn't related to "volatile" as such.