Ray's Knowledge Base
Unlock

std::stoll parses "1.5" as 1 and stoull("-5") wraps, so a truncated literal corrupts a filter

PitfallVerified 29 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A filter that compares an integer column against a non-integral literal matches nothing, although rows match it. In dftracer-utils, zone pruning with a non-integral literal dropped matching chunks and returned 0 rows.

Cause#

std::stoll and integer std::from_chars consume the longest valid prefix and ignore the rest: stoll("1.5") is 1 with no error, and stoull("-5") wraps around. A predicate built from that parse compares the wrong number instead of rejecting the literal or comparing it exactly.

Fix#

Parse number literals fully: reject the input when characters are left over. To compare an int column against a double literal, use one exact int/double comparison helper rather than truncating the literal to an integer.

Evidence#

dftracer-utils duql stage 13a (2026-09-29): the zone-pruning regression test returned 0 rows before the fix and 20 rows after. The fix moved the duql evaluator's exact int/double comparison into a shared helper and used it in zone pruning, so numbers are parsed fully and "1.5" is never read as 1.

Also found by searching

  • filter ts > 1.5 returns 0 rows but matching rows exist, integer column
  • comparing an integer column with a decimal literal silently matches nothing
  • how do I parse a numeric literal in C++ and reject trailing characters
  • std::stoll("1.5") returns 1 no exception, stoull negative wraps around
  • filter on int column with literal 1.5 returns zero rows, zone pruning dropped chunks
  • std::stoll("1.5") returns 1 with no exception, stoull("-5") gives huge number
  • from_chars stops at first invalid char silently, truncated number literal, compare int column against double exactly