[Issue 12013] New: static array of chars implicitly converts to string

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 27 13:03:40 PST 2014


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: nobody at puremagic.com
        ReportedBy: destructionator at gmail.com


--- Comment #0 from Adam D. Ruppe <destructionator at gmail.com> 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: -------


More information about the Digitalmars-d-bugs mailing list