6792 – [CTFE] ICE with pointer cast of indexed array

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6792 - [CTFE] ICE with pointer cast of indexed array
Summary: [CTFE] ICE with pointer cast of indexed array
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
Reported: 2011年10月08日 10:24 UTC by Hisayuki Mima
Modified: 2011年11月02日 13:06 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Hisayuki Mima 2011年10月08日 10:24:56 UTC
struct S{
 int i;
}
static assert({
 {
 void* p;
 p = [S(1)].ptr;
 S s = *(cast(S*)p);// OK
 assert(s.i == 1);
 }
 {
 void*[] ary;
 ary ~= [S(2)].ptr;
 S s = *(cast(S*)ary[0]);// Error: CTFE internal error assigning struct
 assert(s.i == 2);
 }
 {
 void*[string] aa;
 aa["key"] = [S(3)].ptr;
 S s = *(cast(S*)aa["key"]);// Error: CTFE internal error assigning struct
 assert(s.i == 3);
 }
 return true;
}());
The latest dmd built from github cannot compile the above code.
Comment 1 Don 2011年10月10日 01:15:26 UTC
Another case, where it's an lvalue instead of an rvalue:
 {
 void*[7] ary;
 ary[6]= [S(2)].ptr; 
 *(cast(S*)ary[6]) = S(4); //ICE(interpret.c 2965)
 }
The root cause is that type painting of pointers hasn't been considered properly in CTFE.


AltStyle によって変換されたページ (->オリジナル) /