www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24133] New: printf format checking of %n allows writing to

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 puremagic.com
          Reporter: bugzilla 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
}
---

--
Sep 03 2023