Bug 607 – toString can't handle char[]

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-11-27T08:27:00Z
Last change time
2014-02-15T13:28:58Z
Assigned to
bugzilla
Creator
davidl

Comments

Comment #0 by davidl — 2006-11-27T08:27:12Z
in phobos toString only play with char* remember char* is different from char[] i use enki to parse a char[] buf, and set the substrings in buf to be the AA's keys and values, then i tostring AA["Key1"] , i can see not only the AA["key1"] given , but also something in buf all tostringed a simple case couldn't be provided by now, but i think std.string should include a new func char[] toString(char[] s) { return s; }
Comment #1 by davidl — 2006-11-27T09:01:47Z
The problem is actually the compiler can implicitly cast char[] to char* then the toString take char[] in without any warnings or error message shown. but it is dangerous to pass char[] to toString maybe we don't neet the implicitly cast from char[] to char* or we need to provide either of the funcs as the following: char[] toString(char[]s) { static assert(`Error use of toString, u can't toString a String`); } or char[] toString(char[]s) { return }
Comment #2 by bugzilla — 2006-12-12T04:15:19Z
Fixed DMD 0.176