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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 9 00:09:04 PDT 2011


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



--- Comment #8 from Don <clugdbug at yahoo.com.au> 2011-08-09 00:09:02 PDT ---
(In reply to comment #7)
> As far as I can see, D uses the smallest type necessary to fit a character
> literal. So all non-ascii character literals will either be wchar or dchar.
> Both of the following passes, as expected.
> 
> static assert(is(typeof('ä') == wchar));
> static assert(is(typeof('a') == char));

That's good news. Seems like it's only a few cases where it behaves stupidly.

> But I don't know why the compiler allows to assign a wchar to a char array
> element. That doesn't seem right.

It's more general than that:

   wchar w = 'ä';
   char c = w; // Error: cannot implicitly convert expression (w) of type wchar
to char


   char c = 'ä'; // passes!!!

-- 
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