You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Assertion failure when a date is followed by a space and a number (a = 2026-10-13 1) #313
toml++ version and/or commit hash:
3.4.0 per TOML_LIB_MAJOR/MINOR/PATCH, single-header toml.hpp from master at commit 1e8829b. Also reproduces on the v3.4.0 release.
Compiler:
Clang 23.1.3 (Windows, x86_64-pc-windows-msvc). Also seen with Clang 18 on Linux (Ubuntu), where it was first found.
C++ standard mode:
17 (the original finding was under 20)
Target arch:
x64
Library configuration overrides:
None needed; the repro below uses the defaults. It also reproduces with TOML_EXCEPTIONS=0.
Relevant compilation flags: -std=c++17 -O0 -fexceptions, without NDEBUG, so assertions are on.
Describe the bug
When a date value is followed by a space, a digit and then a newline, the parser hits an internal assertion instead of reporting a parse error:
Assertion failed: !is_value_terminator(*cp), file toml.hpp, line 15224
This is the TOML_ASSERT_ASSUME(!is_value_terminator(*cp)); at the top of the scan lambda in parse_value. In a build with NDEBUG defined, TOML_ASSERT_ASSUME becomes TOML_ASSUME, so the same input reaches a false compiler assumption, which is undefined behaviour, in release builds.
I'd expect a normal parse_error, which is what happens when the same text has no trailing newline.
Built with clang++ -std=c++17 -O0 -fexceptions, it prints the assertion failure above and aborts.
What I found while narrowing it down:
a = 2026-10-13 1 with no trailing newline: refused with a normal parse error.
a = 2026-10-13 1\n: assertion.
a = 2026-10-13 1\nb = 2\n: assertion.
a =2026-10-13 1\n (no space after =): assertion.
a = 2026-10-13\n: parses, as expected.
Additional information
Found by fuzzing a loader built on toml++ with libFuzzer, AddressSanitizer and UndefinedBehaviorSanitizer. It looks like the date-time path takes the space as the separator between a date and a time, sees a digit, and then reaches the value scan positioned on the newline.
It seems to be the same kind of reachable precondition as the [[[ table-header case fixed in #301.
Activity