www.digitalmars.com         C & C++   DMDScript  

D - "Incompatible types" for an array initialization expression: bug?

reply "Les Baker" <lesbaker innovaREMOVETHIS.net> writes:
Walter,

Given:
import c.stdio;

int main(char[][] args)
{
    // append null terminator
    wchar[] text = "Test Text." ~ '\u0000';
    return 0;
}

the compiler says:
bug3.d(5): incompatible types for (("Test Text.") ~ (cast(int)(0))):
'char[]' and 'int'

however:
import c.stdio;

int main(char[][] args)
{
    wchar[] text = "Test Text.";
    text ~= '\u0000';

    return 0;
}

compiles without complaint.

Is this a bug?

Thanks -- Les Baker
Aug 15 2003
parent "Walter" <walter digitalmars.com> writes:
Yes, it's a bug. You can workaround by turning '\u0000' into "\u0000".

"Les Baker" <lesbaker innovaREMOVETHIS.net> wrote in message
news:bhk5ta$tm4$1 digitaldaemon.com...
 Walter,

 Given:
 import c.stdio;

 int main(char[][] args)
 {
     // append null terminator
     wchar[] text = "Test Text." ~ '\u0000';
     return 0;
 }

 the compiler says:
 bug3.d(5): incompatible types for (("Test Text.") ~ (cast(int)(0))):
 'char[]' and 'int'

 however:
 import c.stdio;

 int main(char[][] args)
 {
     wchar[] text = "Test Text.";
     text ~= '\u0000';

     return 0;
 }

 compiles without complaint.

 Is this a bug?

 Thanks -- Les Baker
Aug 16 2003