C/C++ errors

C and C++ compiler, linker and runtime errors — undefined references, segfaults, memory corruption and exceptions.

CodeErrorWhat it means
AddressSanitizer: heap-use-after-free C/C++: ==ERROR: AddressSanitizer: heap-use-after-free on address — memory used after delete/free The program read or wrote a heap block after it had been freed; ASan shows who freed it and where it was allo…
AddressSanitizer: heap-buffer-overflow C/C++: ==ERROR: AddressSanitizer: heap-buffer-overflow on address — READ/WRITE of size N AddressSanitizer caught a read or write just outside a heap block — an array index or length that is off by o…
Bus error C/C++: Bus error (core dumped) — SIGBUS from misaligned access or a bad memory-mapped file The CPU or OS rejected a memory access that is not a plain invalid address: misaligned data, or touching a me…
undefined reference to main C/C++: undefined reference to `main' — (.text+0x20) in crt1.o The linker has no `main` function: the file with `main` is not compiled or linked, or `main` is spelled or de…
was not declared in this scope C++: error: 'x' was not declared in this scope (undeclared identifier) The compiler met a name it has never seen: it is misspelled, declared later, out of scope, or its header or n…
control reaches end of non-void function C/C++: warning: control reaches end of non-void function [-Wreturn-type] A function that promises a return value can finish without returning one on some path — undefined behaviour i…
undefined reference to pthread_create C/C++: undefined reference to `pthread_create' — missing -pthread (also `dlopen`, `clock_gettime`) Your program uses threads (or another system library) but the linker was not told to link it.
C2065 MSVC: error C2065: 'x': undeclared identifier Visual C++ met a name it has not seen declared — a typo, a missing header or namespace, or use outside its sc…
runtime error: C/C++: runtime error: signed integer overflow / null pointer / shift exponent too large (UndefinedBehaviorSanitizer) UBSan detected code that triggers undefined behaviour (overflow, null dereference, out-of-bounds index, bad s…
stray in program C/C++: error: stray '\342' in program (smart quotes or invisible characters) The source file contains a character the compiler does not recognise, typically curly quotes or a non-breakin…
std::bad_alloc C++: terminate called after throwing an instance of 'std::bad_alloc' — what(): std::bad_alloc `new` or a container could not get the memory requested — either the system is out of memory or the size was…
terminate called after throwing an instance of C++: terminate called after throwing an instance of 'std::out_of_range' — what(): vector::_M_range_check A C++ exception wasn’t caught anywhere, so std::terminate aborted the program. what() tells you the reason.
Could not find a package configuration file CMake Error: Could not find a package configuration file provided by "Foo" (requested version 1.2) `find_package(Foo)` could not locate the library's CMake config (FooConfig.cmake or FindFoo.cmake), so the li…
double free or corruption C/C++: free(): double free detected / double free or corruption (out) — Aborted (core dumped) Memory was freed twice or the heap was corrupted (buffer overflow, freeing a non-heap pointer), so glibc abor…
expected unqualified-id before C++: error: expected unqualified-id before 'return' / before ')' token The parser found a token where a name (declaration) was required — often a missing brace, a stray `)`, or a s…
format expects argument of type C: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long int' [-Wformat=] The `printf`/`scanf` format specifier does not match the argument's type, which is undefined behaviour and pr…
fatal error: No such file or directory C/C++: fatal error: foo.h: No such file or directory — #include not found The preprocessor cannot find a header named in `#include`: wrong path, missing include directory (-I), or the…
call of overloaded is ambiguous C++: error: call of overloaded 'f(int)' is ambiguous Two or more overloads fit equally well, so the compiler refuses to guess which function you meant.
invalid conversion from C++: error: invalid conversion from 'const char*' to 'char*' [-fpermissive] C++ forbids silently dropping `const` or converting between unrelated pointer types — typically a string lite…
incomplete type C++: error: invalid use of incomplete type 'class X' — forward declaration only You used a class that has only been forward-declared (so its size and members are unknown) where the full def…
undefined reference to vtable C++: undefined reference to `vtable for X' — virtual function not defined The linker cannot find the class's virtual table, which means at least one virtual member function was declar…
LNK1104 MSVC: fatal error LNK1104: cannot open file 'foo.lib' (or 'app.exe' while it is running) The Visual C++ linker could not open an input library or the output file — the path is wrong, the library is…
stack smashing detected C/C++: *** stack smashing detected ***: terminated — buffer overflow on the stack GCC's stack protector noticed that a local buffer overflowed and overwrote the function's canary value, so it…
undefined reference to C/C++: undefined reference to `function' — collect2: error: ld returned 1 exit status The linker can’t find the definition of a function or variable that was declared and used.
comparison of integers of different signs C/C++: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' [-Wsign-compare] A signed integer is compared with an unsigned one; the signed value is converted to unsigned, so a negative n…
does not name a type C++: error: 'string' does not name a type Where the compiler expected a type, it found a name it does not know as one — a missing header, namespace, or…
discards qualifiers C++: error: passing 'const X' as 'this' argument discards qualifiers [-fpermissive] A const object (or const reference) is calling a method that is not declared const, which could modify it.
Assertion failed C/C++: Assertion `x > 0' failed. Aborted (core dumped) — assert() condition was false An `assert()` in your code or in a library found its condition false and aborted the program on purpose.
expected primary-expression before C++: error: expected primary-expression before ')' token The parser expected a value or expression and found a token that cannot start one — often a type name passed…
not a member of std C++: error: 'optional' in namespace 'std' does not name a template type — wrong -std standard The standard-library feature you used needs a newer C++ standard than the compiler is currently set to.
redefinition of C++: error: redefinition of 'class X' / multiple definition — missing include guard The same class, struct or function body was included twice in one translation unit because the header has no…
expected ';' before C/C++: error: expected ';' before 'x' — missing semicolon The compiler reached a token where a statement should have ended — almost always a missing semicolon on the l…
Segmentation fault C/C++: Segmentation fault (core dumped) — SIGSEGV from a null, dangling or out-of-bounds pointer The program touched memory it is not allowed to access — a null or dangling pointer, an out-of-range array in…
use of deleted function C++: error: use of deleted function 'X::X(const X&)' — copying a non-copyable type The code needs a function (usually a copy constructor or assignment) that was deleted explicitly or implicitl…
terminate called without an active exception C++: terminate called without an active exception — std::thread destroyed while joinable A `std::thread` object was destroyed (or reassigned) while its thread was still running, so the C++ runtime c…
stack overflow C/C++: stack overflow — infinite recursion or huge local array (Segmentation fault, 0xC00000FD) The call stack ran out of space, typically from recursion that never stops or from a very large array declare…
is private within this context C++: error: 'int X::secret' is private within this context Code outside the class tried to use a private (or protected) member.
ISO C++ forbids comparison between pointer and integer C++: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] You compared a string literal or pointer with a character or integer — typically `ch == "y"` instead of `ch =…
no match for 'operator' C++: error: no match for 'operator<<' (operand types are 'std::ostream' and 'X') You used an operator on a type that does not define it — most often printing your own class with `
no matching function for call to C++: error: no matching function for call to 'f(int, const char*)' No overload of the function accepts the arguments you passed — wrong count, wrong types, or a missing convers…
No rule to make target Make: *** No rule to make target 'foo.c', needed by 'foo.o'. Stop. `make` was asked to build a file for which there is no rule and no existing file — a missing source, a typo i…
GLIBCXX not found Linux: version `GLIBCXX_3.4.30' not found (required by ./app) — libstdc++.so.6 The program was built with a newer GCC than the libstdc++ installed on the machine where it runs.
implicit declaration of function C: warning: implicit declaration of function 'foo' [-Wimplicit-function-declaration] In C you called a function the compiler has not seen declared — usually a missing `#include`. Newer compilers…
Floating point exception C/C++: Floating point exception (core dumped) — SIGFPE, usually integer division by zero Despite the name, this is almost always an integer division or modulo by zero (or INT_MIN / -1); floating-poi…
multiple definition of C/C++: multiple definition of `x'; first defined here — ld returned 1 exit status The linker found the same function or global variable defined in two object files — usually something defined…
cannot declare variable to be of abstract type C++: error: cannot declare variable 'x' to be of abstract type 'Shape' (pure virtual functions) You tried to create an object of a class that still has pure virtual functions; only a derived class that ove…
need typename before dependent name C++: error: need 'typename' before 'T::iterator' because 'T' is a dependent scope Inside a template, a name like `T::iterator` could be a type or a value, so C++ requires the `typename` keywo…
pure virtual method called C++: pure virtual method called — terminate called without an active exception A pure virtual function was called on an object that is being constructed or destroyed, where the derived par…
missing separator Make: Makefile:5: *** missing separator. Stop. (spaces instead of a tab) A line in the Makefile is neither a rule, a variable assignment nor a tab-indented command — nearly always sp…
C4996 MSVC: error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead Visual C++ treats classic C library functions such as `strcpy`, `sprintf`, `fopen` and `scanf` as deprecated…
LeakSanitizer: detected memory leaks C/C++: ==ERROR: LeakSanitizer: detected memory leaks — Direct leak of N byte(s) At exit, LeakSanitizer found heap blocks that were allocated but never freed and are no longer reachable.
narrowing conversion C++: error: narrowing conversion of 'x' from 'int' to 'char' inside { } [-Wnarrowing] Brace initialisation `{}` refuses conversions that can lose data, such as `double` to `int` or a runtime `int…
template argument deduction/substitution failed C++: error: template argument deduction/substitution failed / couldn't deduce template parameter The compiler could not work out the template arguments from your call — the arguments disagree, the type can'…