[Issue 24133] New: printf format checking of %n allows writing to const pointers

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Sep 3 09:08:47 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=24133

          Issue ID: 24133
           Summary: printf format checking of %n allows writing to const
                    pointers
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com

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
}
---

--


More information about the Digitalmars-d-bugs mailing list