Bug 24363 – hex string postfixes are useless

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-01-30T13:24:16Z
Last change time
2024-01-31T12:44:51Z
Keywords
pull
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2024-01-30T13:24:16Z
Hex strings allow a string postfix like any other string literal, but 'w' and 'd' can't create array elements larger than 255, they just pad each byte from the hex string with 1 or 3 zeros. ``` string a = x"11 22 33 44"c; wstring b = x"1122 3344"w; // equal to [0x0011, 0x0022, 0x0033, 0x0044] dstring c = x"11223344"d; pragma(msg, a.length); // 4 pragma(msg, b.length); // 4 pragma(msg, c.length); // 4 ``` It would be more sensible to make the wstring equal to [0x1122, 0x3344] and the dstring [0x11223344], or to disallow a postfix on a hex string. In any case, the spec should document the behavior.
Comment #1 by bugzilla — 2024-01-30T20:59:36Z
(In reply to Dennis from comment #0) > It would be more sensible to make the wstring equal to [0x1122, 0x3344] and > the dstring [0x11223344], Yes
Comment #2 by dlang-bot — 2024-01-30T23:02:42Z
@dkorpel created dlang/dmd pull request #16118 "Fix bugzilla issue 24363 - hex string postfixes are useless" fixing this issue: - Fix bugzilla issue 24363 - hex string postfixes are useless https://github.com/dlang/dmd/pull/16118
Comment #3 by dlang-bot — 2024-01-31T12:44:51Z
dlang/dmd pull request #16118 "Fix bugzilla issue 24363 - hex string postfixes are useless" was merged into master: - c10c2e2692a0fac640af29c6b06da88cf847960c by Dennis Korpel: Fix bugzilla issue 24363 - hex string postfixes are useless https://github.com/dlang/dmd/pull/16118