Skip to content

Instantly share code, notes, and snippets.

@vobject
Created July 13, 2016 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vobject/1c2916ffa833a98aff2a91f62fadc30f to your computer and use it in GitHub Desktop.
Save vobject/1c2916ffa833a98aff2a91f62fadc30f to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
struct C {};
C* f() { return (C*)0x80000000; }
C* b() { return (C*)0x70000000; }
int main()
{
uint64_t f1 = (uint32_t)f();
uint64_t f2 = (uint64_t)f();
uint64_t f3 = (uint64_t)(uint32_t)f();
uint64_t f4 = (uint64_t)0x80000000;
cout << hex << showbase << "f1="<<f1 << " f2="<<f2 << " f3="<<f3 << " f4="<<f4 << endl;
uint64_t b1 = (uint32_t)b();
uint64_t b2 = (uint64_t)b();
uint64_t b3 = (uint64_t)(uint32_t)b();
uint64_t b4 = (uint64_t)0x70000000;
cout << hex << showbase << "b1="<<b1 << " b2="<<b2 << " b3="<<b3 << " b4="<<b4 << endl;
}
@vobject
Copy link
Author

vobject commented Jul 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment