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.
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.
https://github.com/D-Programming-Language/dmd/commit/3055cc6a8b36a2e00c270b0e48e1d1bd2c931f37 https://github.com/D-Programming-Language/dmd/commit/72e750209b370b66157f320d3517c5816a3951d7
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル