Bug 15887 – invalid char/wchar/dchar values are inconsistently accepted/rejected
Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-04-06T19:12:16Z
Last change time
2020-03-21T03:56:41Z
Keywords
spec
Assigned to
No Owner
Creator
ag0aep6g
Comments
Comment #0 by ag0aep6g — 2016-04-06T19:12:16Z
----
void main()
{
char c = 0xFF; /* accepted */
wchar wc = 0xFF_FF; /* accepted */
dchar dc = 0xFF_FF_FF_FF; /* Error: cannot implicitly convert expression (4294967295u) of type uint to dchar */
string s = x"FF"; /* accepted */
wstring ws = x"FF FF"w; /* Error: Outside Unicode code space */
dstring ds = x"FF FF FF FF"d; /* Error: Outside Unicode code space */
}
----
Should all be accepted. The spec says about hex strings: "The hex data need not form valid UTF characters." - https://dlang.org/spec/lex.html
Comment #1 by b2.temp — 2019-04-04T10:09:46Z
hex strings are about to be removed, so this is a WONTFIX.
Comment #2 by dfj1esp02 — 2019-04-08T12:38:21Z
Unicode code points are limited to 16 planes, so it's unclear if 0xFF_FF_FF_FF should be accepted or not. Some think that it should be seen as a possible value, because it is possible. As to whether it should be allowed as a literal...
Should invalid utf8 text in string literals be accepted too?