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-point division by zero does not raise it by default.
Floating point exception (core dumped)Floating point exception: 80xC0000094 integer divide by zero Meaning
On x86 the CPU traps integer x / 0 and x % 0, and the OS reports SIGFPE as "Floating point exception". Floating-point division by zero normally produces inf or nan instead. Find the divisor that became zero: an empty input, a count that was never incremented, or a loop that starts at 0.
Common causes
- Integer division or modulo by zero (
avg = sum / countwithcount == 0) INT_MIN / -1overflow- Empty container used to compute an average
- Divisor read from input or config that was left at 0
- Unchecked
%in hashing code with table size 0
⚡ Quick fix
- Check the divisor before dividing
- Run under gdb and
btto see the exact line - Compile with
-fsanitize=undefinedto get a clear message
Detailed fix by platform
Linux
gdb ./app→run→btshows the dividing lineg++ -g -fsanitize=undefined main.cppreports "division by zero" with file:line
Windows
- The same bug appears as exception 0xC0000094 (integer divide by zero)
Code examples
Guard the divisor
#include <vector>
#include <numeric>
double average(const std::vector<int>& v) {
if (v.empty()) return 0.0; // avoids dividing by zero
return std::accumulate(v.begin(), v.end(), 0.0) / v.size();
}
int bucket(int hash, int buckets) {
return buckets > 0 ? hash % buckets : 0; // int % 0 would raise SIGFPE
}How to diagnose
- Line — Which expression divides?
- Value — Can the divisor be zero or empty?
- Type — Integer or floating-point?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Bus error C/C++: Bus error (core dumped) — SIGBUS from misaligned access or a bad memory-mapped file
- call of overloaded is ambiguous C++: error: call of overloaded 'f(int)' is ambiguous
- cannot declare variable to be of abstract type C++: error: cannot declare variable 'x' to be of abstract type 'Shape' (pure virtual functions)
Most viewed in C/C++
- terminate called after throwing an instance of C++: terminate called after throwing an instance of 'std::out_of_range' — what(): vector::_M_range_check
- double free or corruption C/C++: free(): double free detected / double free or corruption (out) — Aborted (core dumped)
- undefined reference to C/C++: undefined reference to `function' — collect2: error: ld returned 1 exit status
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026