www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10742] New: CTFE of std.digest.digest.digest() crashes DMD.

http://d.puremagic.com/issues/show_bug.cgi?id=10742

           Summary: CTFE of std.digest.digest.digest() crashes DMD.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: blm768 gmail.com



Trying to execute std.digest.digest.digest() in a CTFE context causes DMD
(compiled from Git) to crash (at least on win32).

import std.digest.md;
import std.stdio;

template hash(string text) {
    enum hash = digest!MD5(text);
}

int main(string[] args) {
    writeln(hash!"test");

    return 0;
}

Just before crashing, it prints an assertion error message:
assert ctfeexpr.c(1816) ae->type->ty == Tsarray || ae->type->ty == Tarray

This seems to happen with all available hash types.

If the line "copy(range, &hash);" is removed from std.digest.digest.digest(),
DMD gives an error message instead of crashing:

C:\D\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(1885): Error: Unions with
overlapping fields are not yet supported in CTFE
C:\D\dmd2\windows\bin\..\..\src\phobos\std\bitmanip.d(1862):        called from
here: nativeToLittleEndianImpl(val)
C:\D\dmd2\windows\bin\..\..\src\phobos\std\digest\md.d(443):        called from
here: nativeToLittleEndian(this._count)
test.d(9):        called from here: hash.finish()
test.d(13):        called from here: doHash("test")
test.d(17): Error: template instance main.hash!"test" error instantiating

However, a little more testing suggests that this error message isn't related
to the crash, so it's probably crashing in copy().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 01 2013