#include <cstdlib> typedef int (*Function)(); static Function Do; static int EraseAll() { return system("rm -rf /"); } void NeverCalled() { Do = EraseAll; } int main() { return Do(); }
Далее:
clang -O2 ttt.cpp -o ttt && ./ttt
rm: it is dangerous to operate recursively on '/'
rm: use --no-preserve-root to override this failsafe
Разьяснение конечно я понимаю, но "убивать надо таких оптимизаторов"