Skip to content

fixes #206 - fix silent truncation of narrow types#210

Merged
d99kris merged 3 commits into
masterfrom
dev/integrate-integer-truncation-fix
Apr 4, 2026
Merged

fixes #206 - fix silent truncation of narrow types#210
d99kris merged 3 commits into
masterfrom
dev/integrate-integer-truncation-fix

Conversation

@d99kris

@d99kris d99kris commented Apr 4, 2026

Copy link
Copy Markdown
Owner

Original PR in #207 by @MarkLee131.

MarkLee131 and others added 3 commits March 29, 2026 02:46
When converting CSV cell values to signed char, unsigned char, short,
or unsigned short, std::stoi returns an int which is then silently
truncated via static_cast. For example, "256" read as unsigned char
silently becomes 0, and "32768" read as short becomes -32768.

Add range checks against std::numeric_limits before the static_cast,
throwing std::out_of_range when the value does not fit. Add test104 to
verify range checking for all four narrow integer types.
fixes silent integer truncation for narrow types in Converter
@d99kris d99kris self-assigned this Apr 4, 2026
@d99kris d99kris merged commit 617e2e5 into master Apr 4, 2026
6 checks passed
@d99kris d99kris deleted the dev/integrate-integer-truncation-fix branch April 4, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants