What | Removed | Added |
---|---|---|
CC | p.remmers@arcor.de |
I must add that I also just stumbled upon this. I was about to file another bug but then found this. I think string literals should always be zero terminated, not just when used as a parameter to a function that takes a char*. Here is a quote from std/string.d (the toStringz() function): * Note that the compiler will put a 0 past the end of static * strings, and the storage allocator will put a 0 past the end * of newly allocated char[]'s. This little test program works on DMD and LDC2, but fails on GDC: int main(string[] argv) { string s = "Hello"; // same with static string s = "Hello"; assert(*(s.ptr + s.length - 1) == 'o'); // OK assert(*(s.ptr + s.length) == '\0'); // fails return 0; } I think it's a bug.