Thread overview
[Issue 14627] Implicit conversion from uint to dchar allows dchar > dchar.max
May 28, 2015
Lionello Lunesu
May 28, 2015
Lionello Lunesu
Jul 02, 2017
Vladimir Panteleev
Dec 17, 2022
Iain Buclaw
May 28, 2015
https://issues.dlang.org/show_bug.cgi?id=14627

Lionello Lunesu <lio+bugzilla@lunesu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Implicit conversion from    |Implicit conversion from
                   |uint to dchar allows dchar  |uint to dchar allows dchar
                   |> dhcar.max                 |> dchar.max

--
May 28, 2015
https://issues.dlang.org/show_bug.cgi?id=14627

--- Comment #1 from Lionello Lunesu <lio+bugzilla@lunesu.com> ---
There are two solutions to this:

1. Make dchar.max == uint.max

2. Make dchar = uint use range checks to determine whether implicit cast is safe


ad 1. This changes dchar.max, but there doesn't appear to be much code depending on it. In fact, Phobos has a couple `if (d > 0x10FFFF)` which don't currently make sense.

ad 2. Generate warning/deprecation when the range falls outside 0..0x10FFFF. breaks some code that assembles a dchar from wchar/char, and fixed by adding casts.

--
October 24, 2015
https://issues.dlang.org/show_bug.cgi?id=14627

thomas.bockman@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thomas.bockman@gmail.com

--- Comment #2 from thomas.bockman@gmail.com ---
The issue of dchar.max versus uint.max has been discussed on the forums:
    http://forum.dlang.org/thread/qjmikijfluaniwnxhigp@forum.dlang.org

It was decided that D compilers must support dchar values which are outside the range of valid Unicode code points; otherwise handling encoding errors and the like gets very awkward. Besides, actually enforcing a range less than that which is actually representable by the binary format of dchar would be very difficult to do in a performant way.

In light of this, I think #1 (Make dchar.max == uint.max) is the correct solution. Allowing dchar.max to be less than its true maximum has probably caused subtle bugs in some generic code.

The value of the maximum code point (0x10FFFF) should be moved to a separate
constant.

--
July 02, 2017
https://issues.dlang.org/show_bug.cgi?id=14627

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3
           Hardware|x86                         |All
                 OS|Mac OS X                    |All

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=14627

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4

--