Created
July 30, 2017 07:54
-
-
Save odeblic/b3e4a4ccf23913fc2e90e1ecfa349fef to your computer and use it in GitHub Desktop.
To be tested...
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 my_int; | |
float my_float; | |
char my_char; | |
long long my_longlong; | |
struct { char a; long long b; } my_aligned; | |
#pragma pack(1) | |
struct { char a; long long b; } my_unaligned; | |
void who_is_right(void) | |
{ | |
asm("nop ; explicit cast from float to int"); | |
my_int = (int) my_float; | |
asm("nop ; explicit cast from int to float"); | |
my_float = (float) my_int; | |
asm("nop ; implicit cast from float to int"); | |
my_int = my_float; | |
asm("nop ; implicit cast from int to float"); | |
my_float = my_int; | |
asm("nop ; access to aligned struct"); | |
my_char = my_aligned.a; | |
my_longlong = my_aligned.b; | |
asm("nop ; access to unaligned struct"); | |
my_char = my_unaligned.a; | |
my_longlong = my_unaligned.b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment