[Issue 509] New: [wd]char[1] does not convert to [wd]char

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 15 03:14:05 PST 2006


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

           Summary: [wd]char[1] does not convert to [wd]char
           Product: D
           Version: 0.174
          Platform: PC
               URL: http://www.digitalmars.com/d/arrays.html
        OS/Version: Windows
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P4
         Component: www.digitalmars.com
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: deewiant at gmail.com


The Arrays spec, under the "Strings" section, has the following example code:

wchar w;
w = \r; // w is assigned the carriage return wchar character

This code does not compile: cannot implicitly convert expression ("\x0d") of
type char[1] to wchar. Trying to explicitly cast it to wchar[1], wchar[], or
wchar also fails with similar error messages.

Yet, the spec says right above this code that "[s]trings a single character in
length can also be exactly converted to a char, wchar or dchar constant".

Which is correct? To solve, change compiler behaviour to make the code compile
and then change the 'w = "b"[0]' part of the code to 'w = "b"', or remove the
sentence quoted and change the 'w = \r' line to 'w = \r[0]'.


-- 




More information about the Digitalmars-d-bugs mailing list