On older macOS std::from_chars for double is unavailable; parse with strtod
PitfallVerified 29 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
A decimal-number parser written with std::from_chars(first, last, double) cannot be used in code that must build on older macOS.
Cause#
The libc++ shipped with older macOS toolchains does not provide the floating-point overload of std::from_chars; only the integer overloads are safe there.
Fix#
Use std::strtod on a null-terminated copy and check that the end pointer reaches the end of the input. Keep std::from_chars for integers.
Evidence#
dftracer-utils duql stage 13a (2026-09-29): the number parser in src/dftracer/utils/duql/numbers.h was switched from std::from_chars(double) to std::strtod with the recorded reason "strtod, not from_chars: the double overload is not on older macOS"; the tests build then compiled clean.
Also found by searching
- error: call to deleted function 'from_chars' double, unavailable on macOS 10.15
- double parsing with from_chars does not compile on older macOS Xcode toolchain
- how do I parse a double from a string_view portably in C++ on old macOS
- libc++ floating point from_chars not supported, use strtod with end pointer check
- error: call to deleted function 'from_chars' / no matching function for std::from_chars(const char*, const char*, double&) on macOS
- double from_chars not available in libc++ older Xcode, build fails for deployment target
- how do I parse doubles portably in C++17 when std::from_chars floating point is missing on macOS?
- use strtod instead of from_chars for float parsing, check end pointer, older Apple clang libc++