Floating point exception C/C++ Origin: Application & API Last updated 15 Oct 2026

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.

Exact message you may see Floating point exception (core dumped)Floating point exception: 80xC0000094 integer divide by zero
Seen on: C/C++ Linux Windows

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 / count with count == 0)
  • INT_MIN / -1 overflow
  • 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

  1. Check the divisor before dividing
  2. Run under gdb and bt to see the exact line
  3. Compile with -fsanitize=undefined to get a clear message

Detailed fix by platform

Linux

  1. gdb ./app → run → bt shows the dividing line
  2. g++ -g -fsanitize=undefined main.cpp reports "division by zero" with file:line

Windows

  1. The same bug appears as exception 0xC0000094 (integer divide by zero)

Code examples

Guard the divisor

cpp
#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

  1. Line — Which expression divides?
  2. Value — Can the divisor be zero or empty?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

Bus error — C/C++: Bus error (core dumped) — SIGBUS from misaligned access or a bad memory-mapped file (C/C++)Bus errorcall of overloaded is ambiguous — C++: error: call of overloaded 'f(int)' is ambiguous (C/C++)call of overloaded is…cannot declare variable to be of abstract type — C++: error: cannot declare variable 'x' to be of abstract type 'Shape' (pure virtual functions) (C/C++)cannot declare variab…runtime error: — C/C++: runtime error: signed integer overflow / null pointer / shift exponent too large (UndefinedBehaviorSanitizer) (C/C++)runtime error:Segmentation fault — C/C++: Segmentation fault (core dumped) — SIGSEGV from a null, dangling or out-of-bounds pointer (C/C++)Segmentation faultstack overflow — C/C++: stack overflow — infinite recursion or huge local array (Segmentation fault, 0xC00000FD) (C/C++)stack overflowstack smashing detected — C/C++: *** stack smashing detected ***: terminated — buffer overflow on the stack (C/C++)stack smashing detect…Floating …

Explore the map of this error Full error map →

🧠 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.