char* を double に変換し、再び char* に戻そうとしています。次のコードは、作成したアプリケーションが 32 ビットの場合は問題なく動作しますが、64 ビット アプリケーションでは動作しません。この問題は、int から char* に変換しようとすると発生します。たとえば、hello = 0x000000013fcf7888 の場合、変換されるのは 0x000000003fcf7888 で、最後の 32 ビットのみが正しいです。
#include <iostream>
#include <stdlib.h>
#include <tchar.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[]){
char* hello = "hello";
unsigned int hello_to_int = (unsigned int)hello;
double hello_to_double = (double)hello_to_int;
cout<<hello<<endl;
cout<<hello_to_int<<"\n"<<hello_to_double<<endl;
unsigned int converted_int = (unsigned int)hello_to_double;
char* converted = reinterpret_cast<char*>(converted_int);
cout<<converted_int<<"\n"<<converted<<endl;
getchar();
return 0;
}