[Issue 7872] dmd should warn if `printf` is used on D strings
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 9 09:35:20 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7872
bearophile_hugs at eml.cc changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bearophile_hugs at eml.cc
--- Comment #1 from bearophile_hugs at eml.cc 2012-04-09 09:36:00 PDT ---
(In reply to comment #0)
> string foo = "john";
> printf("hello %s\n", foo);
>
> doesn't work because `printf` expects a zero-terminated string.
>
> The compiler should really yield a warning here.
In D string literals are zero-terminated. So this run correctly:
import core.stdc.stdio;
void main() {
string foo = "john";
printf("hello %s\n", foo.ptr);
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list