Bug 22001 – Equality of std.conv.toChars() results for radix 10 depends on uninitialized bytes
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-06-07T15:55:45Z
Last change time
2021-06-07T23:25:16Z
Keywords
pull
Assigned to
No Owner
Creator
kinke
Comments
Comment #0 by kinke — 2021-06-07T15:55:45Z
This fails, at least most of the time:
void main()
{
import std.conv;
assert(toChars(123) == toChars(123));
}
Comment #1 by dlang-bot — 2021-06-07T15:58:19Z
@kinke updated dlang/phobos pull request #8133 "std.conv: Avoid undefined bytes in toChars() results for radix 10" fixing this issue:
- Fix Issue 22001 - Avoid undefined bytes in std.conv.toChars() results for radix 10
The buffer is initialized from right-to-left in initialize(), and unused
bytes are left alone. Previously, the whole result wasn't preinitialized
with T.init, so the unused buffer bytes weren't well-defined. Initialize
it now (with zeros), as the whole buffer is still used for equality/
identity comparisons etc.
https://github.com/dlang/phobos/pull/8133
Comment #2 by dlang-bot — 2021-06-07T23:25:16Z
dlang/phobos pull request #8133 "std.conv: Avoid undefined bytes in toChars() results for radix 10" was merged into master:
- ec615eac50b6596cfeed3394d301301657c1ebfa by Martin Kinkelin:
Fix Issue 22001 - Avoid undefined bytes in std.conv.toChars() results for radix 10
The buffer is initialized from right-to-left in initialize(), and unused
bytes are left alone. Previously, the whole result wasn't preinitialized
with T.init, so the unused buffer bytes weren't well-defined. Initialize
it now (with zeros), as the whole buffer is still used for equality/
identity comparisons etc.
https://github.com/dlang/phobos/pull/8133