Value Too Large for Defined Data Type
Production Risk
Common issue when 32-bit code encounters files larger than 2GB; always compile with LFS support.
EOVERFLOW (errno 75) is returned when a value is too large to be stored in the data type used to receive it. Most commonly occurs with file sizes or offsets that exceed what a 32-bit type can hold on a 32-bit system.
- 1stat() on a file larger than 2GB on a 32-bit process without _FILE_OFFSET_BITS=64
- 2read() or lseek() with an offset beyond 32-bit range on a 32-bit binary
- 3st_size field overflow in struct stat on large files
stat() on a large file from a 32-bit binary.
// 32-bit binary, file > 2GB
struct stat st;
stat("/data/largefile.img", &st);
// Returns -1, errno = EOVERFLOWexpected output
stat: Value too large for defined data type (EOVERFLOW)
Fix 1
Compile with large file support
WHEN When accessing files larger than 2GB from 32-bit code
// Add to compilation flags:
// -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
// Or use 64-bit variants explicitly:
struct stat64 st;
stat64("/data/largefile.img", &st);Why this works
_FILE_OFFSET_BITS=64 remaps stat/off_t to 64-bit variants transparently.
Fix 2
Build as a 64-bit binary
WHEN For new code on 64-bit systems
# Compile as 64-bit (default on x86_64) gcc -m64 -o myprogram myprogram.c
Why this works
64-bit binaries use 64-bit off_t natively, avoiding EOVERFLOW entirely.
✕ Ignore EOVERFLOW and use the returned value anyway
The value is truncated and incorrect; using it leads to data corruption or incorrect behavior.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev