Skip to content

Instantly share code, notes, and snippets.

@dodikk
Created March 5, 2015 10:33
Show Gist options
  • Save dodikk/26fe5bdcab36bd88d9b1 to your computer and use it in GitHub Desktop.
Save dodikk/26fe5bdcab36bd88d9b1 to your computer and use it in GitHub Desktop.
Implicit casting int ==> BOOL
int x;
BOOL* px = reinterpret_cast<BOOL*>(&x);
BOOL castedAndTruncated = *px;
// так - точно “обрежет”. Но чтобы compiler такое сам творил…
BOOL x = ^BOOL() { return (BOOL)100500; }
if (x) { // а вот тут - скандалы-интриги-расследования
int x = 100500;
if (x) { // тут обрезания не будет
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment