Bug 20527 – std.json CTFE cannot read integer

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-23T13:00:13Z
Last change time
2020-01-23T17:16:48Z
Keywords
pull
Assigned to
No Owner
Creator
Steven Schveighoffer

Comments

Comment #0 by schveiguy — 2020-01-23T13:00:13Z
std.json has a quirky implementation of integer parsing where it parses a ulong for non-negative numbers, but then sets the tag to point at a long. This gives CTFE fits because you are setting one member of a union, then reading a different member. Code to reproduce: static assert(parseJSON(`{ "int": 2}`)["int"].integer == 2); Error: reinterpretation through overlapped field integer is not allowed in CTFE Easy to fix, set the correct union member.
Comment #1 by dlang-bot — 2020-01-23T13:35:07Z
@schveiguy created dlang/phobos pull request #7361 "Fix issue 20527. Set the correct union member for integers so CTFE" fixing this issue: - Fix issue 20527. Set the correct union member for integers so CTFE doesn't get confused. https://github.com/dlang/phobos/pull/7361
Comment #2 by dlang-bot — 2020-01-23T17:16:48Z
dlang/phobos pull request #7361 "Fix issue 20527. Set the correct union member for integers so CTFE" was merged into stable: - dbd4a2c0a5986b510d9d04af2d833339a28383b2 by Steven Schveighoffer: Fix issue 20527. Set the correct union member for integers so CTFE doesn't get confused. https://github.com/dlang/phobos/pull/7361