Currently Visual C++ is shipped with runtime where malloc()
is decorated with __declspec( restrict )
.
MSDN says this decoration states to the compiler that a pointer returned by malloc()
cannot be aliased by any other pointer. Okay, two subsequent calls to malloc()
indeed return distinct pointers. But what happens if I call
void* memory1 = malloc( 10 );
free( memory1 );
void* memory2 = malloc( 10 );
//here memory1 may be equal to memory2
In this case the two pointers can point to the very same location. How does this correlate with cannot be aliased by any other pointer implication of __declspec( restrict )
?