Does reinterpret_casting an integral to a pointer type and back yield the same value?

后端 未结 2 1718
失恋的感觉
失恋的感觉 2020-12-11 19:31

According to http://en.cppreference.com/w/cpp/language/reinterpret_cast, it is known that reinterpret_cast a pointer to an integral of sufficient size and back

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-11 20:07

    I get exactly this problem in library exporting pointers to objects as opaque identifiers and now attempting to recover these pointers from external calls don't work for old x86 CPU's (in the time of windows 98). So, while we can expect that behaviour, this is false in general case. In 386-CPU the address is composed by overlapped pointers so the address of any memory position is not unique, and I found that conversion back don't recover original value.

提交回复
热议问题