https://d.puremagic.com/issues/show_bug.cgi?id=11837
--- Comment #4 from yebblies <[email protected]> 2013-12-29 14:53:09 EST --- (In reply to comment #3) > (In reply to comment #2) > > Code like this will compile: > > > > memcmp(ptr, "abc", 3); > > What's wrong with `memcmp(ptr, "abc".ptr, 3)`? > Adding .ptr looses the guarantee that the string will be 0-terminated. eg // enum x = "abc"; // immutable x = "abc"; auto x = "abc"; memcmp(ptr, x.ptr, 4); // oops, no guarantee x is 0-terminates, but the compiler has no way to know that's what you wanted. > I seem to remember there is an issue with null termination in this kind of > useage? ...? The fact that string literals don't convert to const(void)* is IMO an annoying special case. This works: const(char)* x = "askjldfg"; const(void)* y = x; But this doesn't: const(void)* y = "askjldfg"; Unless there's a good reason this has to be prevented... -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
