Created
March 5, 2015 10:33
-
-
Save dodikk/26fe5bdcab36bd88d9b1 to your computer and use it in GitHub Desktop.
Implicit casting int ==> BOOL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int x; | |
| BOOL* px = reinterpret_cast<BOOL*>(&x); | |
| BOOL castedAndTruncated = *px; | |
| // так - точно “обрежет”. Но чтобы compiler такое сам творил… |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BOOL x = ^BOOL() { return (BOOL)100500; } | |
| if (x) { // а вот тут - скандалы-интриги-расследования | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int x = 100500; | |
| if (x) { // тут обрезания не будет | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment