c - What does this mean?: *(int32 *) 0 = 0; -
in following piece of code, *(int32 *) 0 = 0;
mean?
void function (void) { ... (;;) *(int32 *) 0 = 0; /* line do? */ }
a few notes:
- the code seems not reachable, there exit statement before particular piece of code.
int32
typedef
'ed shouldn't care it.- this piece of code language's runtime in compiler, interested.
the code doing following:
(;;) // while(true) *(int32 *) 0 = 0; // treat 0 address, de-reference 0 address , try , store 0 it.
this should segfault, null pointer de-reference.
edit
compiled , ran further information:
#include <stdio.h> #include <stdlib.h> #include <stdint.h> int main(void){ *(int32_t *) 0 = 0; printf("done\n"); return 0; }
gcc -g null.c; ./a.out
program received signal sigsegv, segmentation fault. 0x00000000004004cd in main () @ null.c:7 7 *(int32_t *) 0 = 0;
Comments
Post a Comment