[Issue 11535] CTFE ICE on reassigning a static array initialized with block assignment

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Apr 21 00:30:34 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=11535

Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> ---
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.

--


More information about the Digitalmars-d-bugs mailing list