www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24363] New: hex string postfixes are useless

https://issues.dlang.org/show_bug.cgi?id=24363

          Issue ID: 24363
           Summary: hex string postfixes are useless
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl

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.

--
Jan 30