Thread overview
wchar[]/dchar[] dup
Apr 23, 2005
Thomas Kuehne
Apr 24, 2005
Walter
Apr 24, 2005
Thomas Kühne
April 23, 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

# wchar[] c = "a".dup;

dmd: cannot implicitly convert expression (_adDup("abc",1)) of type char[] to wchar[]

Fails to compile but should compile.

Added to DStress as
http://dstress.kuehne.cn/run/dup_06.d
http://dstress.kuehne.cn/run/dup_07.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFCajJR3w+/yD4P9tIRAhsIAJ0e5kqU4DG/k0TyOMXRGigKnKhvIACbBAWo
8iYG9lSbvgT8Bwc7t8rsMvA=
=P8ET
-----END PGP SIGNATURE-----
April 24, 2005
"Thomas Kuehne" <thomas-dloop@kuehne.thisisspam.cn> wrote in message news:ibopj2-3qi.ln1@lnews.kuehne.cn...
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> # wchar[] c = "a".dup;
>
> dmd: cannot implicitly convert expression (_adDup("abc",1)) of type char[]
to wchar[]
>
> Fails to compile but should compile.

I disagree. If the string literal is forced to commit to a type, which it must with the .dup, it goes with char[].


April 24, 2005
Walter wrote:
| "Thomas Kuehne" <thomas-dloop@kuehne.thisisspam.cn> wrote in message
| news:ibopj2-3qi.ln1@lnews.kuehne.cn...
|>
|># wchar[] c = "a".dup;
|>
|>dmd: cannot implicitly convert expression (_adDup("abc",1)) of type
|>char[]
|
| to wchar[]
|
|>Fails to compile but should compile.
|
| I disagree. If the string literal is forced to commit to a type, which
| it must with the .dup, it goes with char[].

Treating this code as illegal was indeed my first reaction and seems
natural.

The reason for posting this was basically the same as Brad Beveridge's
in "Segfault from changing a string".
The different syntax for assigning a value to an editable wchar/dchar[]
on Linux and Windows is a nice bug trap for Windows-based coders.

Windows:
# char[] c="123;
# c[0]='4';
#
# wchar[] w="abc";
# w[0]='D';

Linux:
# char[] c="123".dup;
# c[0]='4';
#
# wchar[] w="abc";
# w=w.dup;
# w[0]='C';

Please unify the behaviour.

I've removed both tests for now.

Thomas