<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - %ll should not trigger -Wformat with int64_t on 64-bit Linux"
   href="https://bugs.llvm.org/show_bug.cgi?id=44995">44995</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>%ll should not trigger -Wformat with int64_t on 64-bit Linux
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Driver
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>husseydevin@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>On Linux 64-bit, int64_t is defined as "long" to fit the ABI, and is a 64-bit
integer.

This is fine, as otherwise it would be <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - clang's definition of int64_t in stdint.h is wrong on x86-64 Linux"
   href="show_bug.cgi?id=4192">bug 4192</a>. int64_t is always 64 bits.

For printf, %ll is a common idiom to print a 64-bit long long int, and on all
current platforms, long long int is 64 bits. 

#include <stdio.h>
#include <stdint.h>

int main(void)
{
    int64_t x = 0x1234848943922;
    printf("%016llx\n", x);
}

test.c:7:25: warning: format specifies type 'long long' but the argument has
type 'int64_t' (aka 'long') [-Wformat]
    printf("%016llx\n", x);
            ~~~~~~~     ^
            %016lx
1 warning generated.

Naturally, this code will always work on every major ABI unless someone decides
to break decades of working code with a weird RISCV128 ABI (which the ABI
proposal suggesting that it will not).

Is this REALLY worth a warning?

The diagnostic clearly knows the name of the typedef, so a special case could
be made (pseudocode, not going to look up the LLVM API because I will get lost
:P)

 if (type.isTypedef() && type.typedefName().contains("int64") &&
type.sizeInBits() == longLongType.sizeInBits())
    doNotWarn();</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>