Niall Douglas wrote
On 31 Aug 2015 at 20:39, Andrey Semashev wrote: Please do correct me if I am wrong, but I had thought that this is defined behaviour:
int a=5; void *b=(void *)(size_t) a; int c=(int)(size_t) b; assert(c==a);
This is certainly a very common pattern in C.
Although it's a common pattern, it's not correct. It has UB since the standard doesn't guarantee that sizeof(void*) == sizeof(int). The issues arise in 64 bit systems where memory addresses are 64 bits wide and int is 32 bits wide. The safe way to handle integer conversion of pointers is through std::intptr_t, which only purpose is to give an integer type guaranteed to have same width as ptrs. -- View this message in context: http://boost.2283326.n4.nabble.com/AFIO-Formal-review-tp4679535p4679636.html Sent from the Boost - Dev mailing list archive at Nabble.com.