We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Segmentation fault
- Not to be confused with Segmentation Fault.
Segmentation fault is Nope. but every "Nope." is changed with a segmentation fault.
Implementation
C
#include <stdio.h>
int main(void)
{
scanf("");
char *s = "no use lol";
*s = 'H';
}
This works in most modern operating systems and major C compilers as string literals are placed in the rodata (read-only data) section. Since this data is stored in a read-only memory page by the OS when the executable is loaded, writing to it will trigger some kind of protection fault. Some compilers might put string literals in the data section instead, however.
Much shorter one (85 bytes > 53 bytes)
#include <stdio.h>
int main(){scanf("");return*NULL;}
Another one
#include <stdio.h>
int f()
{
return f();
}
int main()
{
scanf("");
return f();
}
Causes a stack overflow, which on most modern operating systems will cause a segmentation fault.
C++
Depends.
#include <cstdio>
int main(){scanf("");int x;delete[]&x;}
#include <cstdio>
int main(){scanf("");delete[]((int*)nullptr+1);}
These ones might not work if your C++ standard library implementation has new and delete as thin wrappers over malloc and free.
#include <cstdio>
#include <cstdlib>
int main(){scanf("");free(new int[99]);}
#include <cstdio>
#include <cstdlib>
int main(){scanf("");delete[]malloc(10);}
These work since ISO C++ does not require nor guarantee that malloc/free uses the same allocator as new/free.
Pascal
function nope(x: int8): int8; begin nope(0); end; begin readln(); nope(0); end.
This works by causing a stack overflow.
Python
import ctypes a=input() if a==a: ctypes.string_at(0)