[llvm-bugs] [Bug 50946] New: format-pedantic warns about passing nullptr to %p

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 30 10:00:00 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50946

            Bug ID: 50946
           Summary: format-pedantic warns about passing nullptr to %p
           Product: clang
           Version: 12.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eyalroz1 at gmx.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Godbolt: https://godbolt.org/z/1dMKE1W81

If we compile:

  #include <stdio.h>

  int main()
  {
      printf("%p\n", nullptr);
  }

with clang++ -Wformat -pedantic, we get:

<source>:5:20: warning: format specifies type 'void *' but the argument has
type 'nullptr_t' [-Wformat-pedantic]
    printf("%p\n", nullptr);
            ~~     ^~~~~~~

I believe that's _too_ pedantic. It is well and proper to pass nullptr to a %p
without casting it.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210630/ca93b715/attachment-0001.html>


More information about the llvm-bugs mailing list