Bug 11535 – CTFE ICE on reassigning a static array initialized with block assignment

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-17T03:57:00Z
Last change time
2014-04-21T12:47:03Z
Keywords
CTFE, ice, pull
Assigned to
nobody
Creator
temtaime

Comments

Comment #0 by temtaime — 2013-11-17T03:57:56Z
import std.digest.md; string md5(string s) { return s.md5Of.toHexString; } struct C { string random_state = md5(`TEST`); } ctfeexpr.c:1833: void recursiveBlockAssign(ArrayLiteralExp*, Expression*, bool): Assertion `ae->type->ty == Tsarray || ae->type->ty == Tarray' failed.
Comment #1 by yebblies — 2013-11-17T07:20:24Z
This boils down to something like ubyte[3] arr; arr = arr.init; arr = [1, 2, 3]; But not exactly that. recursiveBlockAssign fails because the rhs is a ubyte
Comment #2 by yebblies — 2013-11-20T08:28:00Z
*** Issue 10742 has been marked as a duplicate of this issue. ***
Comment #3 by k.hara.pg — 2014-04-21T07:30:34Z
Reduced test case: struct Hash11535 { ubyte[6] _buffer; void put(scope const(ubyte)[] data...) { uint i = 0, index = 0; auto inputLen = data.length; (&_buffer[index])[0 .. inputLen-i] = (&data[i])[0 .. inputLen-i]; } } auto md5_digest11535(T...)(scope const T data) { Hash11535 hash; hash.put(cast(const(ubyte[]))data[0]); return hash._buffer; } static assert(md5_digest11535(`TEST`) == [84, 69, 83, 84, 0, 0]); Compiler fix: https://github.com/D-Programming-Language/dmd/pull/3479 Note that the OP code would not work because std.digest.md does not support CTFE.
Comment #4 by github-bugzilla — 2014-04-21T12:47:02Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/64c27cbdefcf63442dc75b5ffab0227475d60b43 fix Issue 11535 - CTFE ICE on reassigning a static array initialized with block assignment https://github.com/D-Programming-Language/dmd/commit/0a95cd474fe1d17ee88aa47552094bd8535fbd9e Merge pull request #3479 from 9rnsr/fix11535 Issue 11535 - CTFE ICE on reassigning a static array initialized with block assignment