[Issue 6458] Multibyte char literals shouldn't implicitly convert to char

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 8 21:53:06 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6458


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmx.com


--- Comment #1 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-08-08 21:53:05 PDT ---
Personally, I think that all character literals should be typed as dchar, since
it's generally a _bad_ idea to operate on individual chars or wchars. Normally,
the only places that chars or wchars should be used is in ranges of chars or
wchars (which would normally be arrays). But making character literals dchar be
default might break too much code at this point. Though, since it should be
possible to use range propagation to verify whether a particular code point
will fit in a particular code unit, the breakage might be minimal.

Regardless, I actually never would have expected s[0 .. 2] = 'ä' to work, since
you're assigning a character to multiple characters as far as types go, though
I can see why you might think that it would work or why it arguably _should_
work. Obviously though, if the compiler is allowing you to assign a code point
to multiple code units like that, it should only compile if it can verify that
the code unit will fit exactly in those code units, and if it does compile, it
should work correctly rather than generate garbage. So, there are several
issues at work here it seems.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list