Quantcast
Viewing all articles
Browse latest Browse all 1175

Bug with printf("%ju")

When I compile the following code:

#include
#include

int main(int argc, char* argv[])
{
    uintmax_t ui = 1;
    intmax_t si = -1;
    printf ("%ju, %jd\n", ui, si);
    return 0;
}

With these flags:

icc -w3 -std=c99 printf_bug.c

I get these remarks:

printf_bug.c(8): remark #181: argument of type "uintmax_t={unsigned long}" is incompatible with format "%ju", expecting argument of type "unsigned long long"
      printf ("%ju, %jd", ui, si);
                          ^

printf_bug.c(8): remark #181: argument of type "intmax_t={long}" is incompatible with format "%jd", expecting argument of type "long long"
      printf ("%ju, %jd", ui, si);
                              ^

However, the C99 standard defines the length modifier "j" as taking a argument of type uintmax_t/intmax_t. The same problem occurs with equivalent C++11 code. On this platform, long, long long, and uintmax_t are all 64 bits, so I feel safe ignoring the remark.

Version: icc (ICC) 16.0.4 20160811
Architecture: x86_64
OS: RHEL 7.4


Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>