Bug 24732 – FAQ article is out of date on calling printf
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-08-30T12:16:51Z
Last change time
2024-09-05T11:10:22Z
Keywords
pull
Assigned to
No Owner
Creator
Nick Treleaven
Comments
Comment #0 by nick — 2024-08-30T12:16:51Z
https://dlang.org/articles/faq.html#printf
"Attempting this in D, as in:
string s;
s = "foo";
printf("string = '%s'\n", s);
usually results in garbage being printed, or an access violation"
Passing an array as a C variadic parameter is a compile-time error.
> In D, strings are not 0 terminated
The FAQ should also mention that string literals are 0-terminated.
PR incoming.
Comment #1 by dlang-bot — 2024-08-30T19:50:34Z
@ntrel created dlang/dlang.org pull request #3902 "[spec/faq] Improve printf docs" fixing this issue:
- [spec/faq] Improve printf docs
writef replaces printf, not writefln.
Add `RUNNABLE_EXAMPLE`s.
Use monospace for printf specifiers.
Add stdio import.
Mention pragma(printf).
Show string literal with `%s`.
Fix Bugzilla 24732 - FAQ article is out of date on calling printf.
https://github.com/dlang/dlang.org/pull/3902
Comment #2 by dlang-bot — 2024-09-05T11:10:22Z
dlang/dlang.org pull request #3902 "[spec/faq] Improve printf docs" was merged into master:
- f6508697157973ae0cf330f7a8ac6e393233f1a9 by Nick Treleaven:
[spec/faq] Improve printf docs
writef replaces printf, not writefln.
Add `RUNNABLE_EXAMPLE`s.
Use monospace for printf specifiers.
Add stdio import.
Mention pragma(printf).
Show string literal with `%s`.
Fix Bugzilla 24732 - FAQ article is out of date on calling printf.
https://github.com/dlang/dlang.org/pull/3902