D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5113 - (D1 only): stray e2ir: in casting error message
Summary: (D1 only): stray e2ir: in casting error message
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other All
: P4 minor
Assignee: No Owner
URL:
Keywords: ice
Depends on:
Blocks:
 
Reported: 2010-10-24 15:19 UTC by Michael Parrott
Modified: 2013-11-16 21:57 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Michael Parrott 2010-10-24 15:19:54 UTC
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 yebblies 2012-02-15 19:50:08 UTC
*** Issue 7514 has been marked as a duplicate of this issue. ***
Comment 2 bearophile_hugs 2012-04-20 17:53:19 UTC
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 Denis Shelomovskii 2013-11-09 10:28:44 UTC
Issue 7514 isn't a dup and can't at least because it's D2 issue.
Comment 4 Maxim Fomin 2013-11-09 11:55:12 UTC
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 Maxim Fomin 2013-11-09 12:06:38 UTC
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 Denis Shelomovskii 2013-11-09 12:51:05 UTC
(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 yebblies 2013-11-16 20:38:06 UTC
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 Denis Shelomovskii 2013-11-16 21:53:45 UTC
(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.
Comment 9 yebblies 2013-11-16 21:57:54 UTC
Andrei has been closing them, D1 is dead.