https://d.puremagic.com/issues/show_bug.cgi?id=12013

           Summary: static array of chars implicitly converts to string
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Adam D. Ruppe <[email protected]> 2014-01-27 
13:03:36 PST ---
// note: this is NOT pure, so it isn't the pure != unique bug
char[8] test() {
    char[8] tmp;
    tmp[0 .. 8] = "deadbeef"; // fill it with something printable
    return tmp;
}

string wtf() {
    return test(); // this isn't sane!
}

void main() {
    string a = wtf();
    assert(0, a); // prints garbage; it points to reused stack data
}


This also affects Phobos std.digest, which returns a static array of chars with
toHexString.

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

Reply via email to