Bug 24133 – printf format checking of %n allows writing to const pointers

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-09-03T09:08:47Z
Last change time
2023-09-03T12:10:32Z
Keywords
diagnostic, pull
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=21605

Comments

Comment #0 by bugzilla — 2023-09-03T09:08:47Z
Consider: --- pragma(printf) extern (C) int printf(const(char)* fmt, ...); void test(int* p, const int* pc) { printf("%n\n", p); // compiles correctly without error printf("%n\n", pc); // should not compile as p points to const } ---
Comment #1 by dlang-bot — 2023-09-03T10:06:23Z
@WalterBright created dlang/dmd pull request #15569 "fix Issue 24133 - printf format checking of %n allows writing to cons…" fixing this issue: - fix Issue 24133 - printf format checking of %n allows writing to const pointers https://github.com/dlang/dmd/pull/15569
Comment #2 by dlang-bot — 2023-09-03T12:10:32Z
dlang/dmd pull request #15569 "fix Issue 24133 - printf format checking of %n allows writing to cons…" was merged into master: - 9e47262906cb713b1d754a4daeb098594c7eff82 by Walter Bright: fix Issue 24133 - printf format checking of %n allows writing to const pointers https://github.com/dlang/dmd/pull/15569