void main()
{
char c = cast(int)" ";
}
gives:
stringtocharcast.d(3): Error: e2ir: cannot cast " " of type char[1u] to type int
Since that is the only error message I could find with e2ir: in front of it, I'll assume it's unintentional. The error message occurs on line 3901 of e2ir.c in the dmd 1.064 source.
default:
if (fty == tty)
goto Lpaint;
//dump(0);
//printf("fty = %d, tty = %d\n", fty, tty);
error("e2ir: cannot cast %s of type %s to type %s", e1->toChars(), e1->type->toChars(), t->toChars());
goto Lzero;
Not sure if this is in D2 as well.
Comment #1 by yebblies — 2012-02-15T19:50:08Z
*** Issue 7514 has been marked as a duplicate of this issue. ***
Comment #2 by bearophile_hugs — 2012-04-20T17:53:19Z
Similar case:
int main() {
float[1] a;
return cast(int)a;
}
test2.d(3): Error: e2ir: cannot cast a of type float[1u] to type int
Comment #3 by verylonglogin.reg — 2013-11-09T10:28:44Z
Issue 7514 isn't a dup and can't at least because it's D2 issue.
Comment #4 by maxim — 2013-11-09T11:55:12Z
And what benefits brings cast from static float array as a whole to single integer? I can understand advantages of casting static float array with exactly 1 element, but why bother to make a special case? Is it too compilcated to have 'arr[0]' instead of 'arr' and having consistency?
Comment #5 by maxim — 2013-11-09T12:06:38Z
The code
void main()
{
char c = cast(int)" ";
}
is likely to be flawed because what it may produce taking into account D language is conversion from dynamic char array (it may be first/last 4 bytes of address/length depending on what cast from dynamic array mean) to 4 byte integer and then truncate to 1 byte char implicitly.
Comment #6 by verylonglogin.reg — 2013-11-09T12:51:05Z
(In reply to comment #4)
> And what benefits brings cast from static float array as a whole to single
> integer?
An ICE. This report is only about it.
Comment #7 by yebblies — 2013-11-16T20:38:06Z
Duplicate or wontfix, D1 is dead and 7514 is the same issue.
*** This issue has been marked as a duplicate of issue 7514 ***
Comment #8 by verylonglogin.reg — 2013-11-16T21:53:45Z
(In reply to comment #7)
> Duplicate or wontfix, D1 is dead and 7514 is the same issue.
>
> *** This issue has been marked as a duplicate of issue 7514 ***
Yes but we still have lots of "D1 only" issues. You can propose to WONTFIX them all but closing only this one is inconsistent.