Skip to content

Instantly share code, notes, and snippets.

@polymorphm
Last active November 14, 2018 20:58
Show Gist options
  • Save polymorphm/2e4bdc3fc293f20a652fcfdbb24baaf6 to your computer and use it in GitHub Desktop.
Save polymorphm/2e4bdc3fc293f20a652fcfdbb24baaf6 to your computer and use it in GitHub Desktop.
// gcc -Wall -Wextra -o hrenov-kompilator hrenov-kompilator.c
// or: gcc -Wall -Wextra -O3 -o hrenov-kompilator hrenov-kompilator.c
// or: clang -Wall -Wextra -o hrenov-kompilator hrenov-kompilator.c
// or: clang -Wall -Wextra -O3 -o hrenov-kompilator hrenov-kompilator.c
#include <stdlib.h>
#include <stdio.h>
int
main (int argc __attribute__ ((unused)),
char *argv[] __attribute__ ((unused)))
{
int rv = 0;
void *g = 0; // изначально пусть указатель будет нулевым
g = &&out; // а теперь мы его инициализировали
if (!g)
{
fprintf (stderr, "я хренов-компилятор который не позволяет отличить "
"инициализированное значение указателя от нулевого\n");
rv = 1;
goto *g; // переход по нулевому указателю? и без segmentation fault? ОРИГИНАЛЬНО!
}
printf ("g is at %lx address\n", (unsigned long) g);
out:
return rv;
}
// vi:ts=4:sw=4:et
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment