www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.ide
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics



digitalmars.D.bugs - [Issue 2083] New: Cannot convert char[] to string

↑ ↓ ← d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2083

           Summary: Cannot convert char[] to string
           Product: D
           Version: 2.012
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: jlquinn optonline.net


This is really ugly.  The following program:

void test(char[] s) {
  string t = s;
}

gives the following error:

junk2.d(2): Error: cannot implicitly convert expression (s) of type char[] to
invariant(char)[]

I haven't found a way around this yet.  It really should be handled as an
implicit conversion, with a copy being made under the covers as needed.


-- 
May 08 2008
→ "Janice Caron" <caron800 googlemail.com> writes:
On 08/05/2008, d-bugmail puremagic.com <d-bugmail puremagic.com> wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=2083

            Summary: Cannot convert char[] to string
            Product: D
            Version: 2.012
           Platform: PC
         OS/Version: Linux
             Status: NEW
           Severity: normal
           Priority: P2
          Component: DMD
         AssignedTo: bugzilla digitalmars.com
         ReportedBy: jlquinn optonline.net


  This is really ugly.  The following program:

  void test(char[] s) {
   string t = s;
  }

  gives the following error:

  junk2.d(2): Error: cannot implicitly convert expression (s) of type char[] to
  invariant(char)[]

And so it should. That /is/ an error, and a serious one.
  I haven't found a way around this yet.

string t = s.idup;
  It really should be handled as an
  implicit conversion, with a copy being made under the covers as needed.

A copy is made when you add ".idup", but D doesn't like to make silent copies "under the covers as needed".
May 08 2008
→ d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2083


kamm-removethis incasoftware.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE




------- Comment #2 from kamm-removethis incasoftware.de  2008-05-09 01:03
-------


*** This bug has been marked as a duplicate of 2082 ***


-- 
May 08 2008