dchar undefined behaviour
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Fri Oct 23 05:15:37 PDT 2015
On 10/22/2015 6:31 PM, tsbockman wrote:
> So, this leads to the question: is making use of dchar values greater than
> dchar.max considered undefined behaviour, or not?
>
> 1. If it is UB, then there is quite a lot of D code (including std.uni) which
> must be corrected to use uint instead of dchar when dealing with values which
> could possibly fall outside the officially supported range.
>
> 2. If it is not UB, then the compiler needs to be updated to stop assuming that
> dchar values greater than dchar.max are impossible. This basically just means
> removing some of dchar's special treatment, and running it through more of the
> same code paths as uint.
I think that ship has sailed. Illegal values in a dchar are not UB. Making it UB
would result in surprising behavior which you've noted. Also, this segues into
what to do about string, wstring, and dstring with invalid sequences in them.
Currently, functions defined what they do with invalid sequences. Making it UB
would be a burden to programmers.
More information about the Digitalmars-d
mailing list