Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Bug with printf("%ju")

Daniel_P_
Beginner
1,204 Views
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
0 Kudos
4 Replies
Yuan_C_Intel
Employee
1,205 Views

Hi, Daniel

Have you tried your test with our latest version 18.0?

If it's still reproducible, please report bugs to Intel Online Service center , you will get a response from our support team then.

Thanks

Yolanda

 

 

0 Kudos
Quinson__Martin
Beginner
1,205 Views

I confirm that this bug is still present in the version 18.0.3.20180410. I get the following error message:

error #181: argument of type "intmax_t={__intmax_t={long}}" is incompatible with format "%jd", expecting argument of type "long long"
0 Kudos
Viet_H_Intel
Moderator
1,205 Views

 

If you compiled your test case at default, then you don't see the warning. 

vahoang@orcsle147:/tmp$ gcc -std=c99 t.c -c
vahoang@orcsle147:/tmp$ icc -std=c99 t.c -c -V
Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 18.0.3.222 Build 20180410
Copyright (C) 1985-2018 Intel Corporation.  All rights reserved.

Edison Design Group C/C++ Front End, version 4.13 (Apr 10 2018 02:35:14)
Copyright 1988-2017 Edison Design Group, Inc.

vahoang@orcsle147:/tmp$ cat t.c
#include<stdio.h>
#include<stdint.h>

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

This remark is very low priority, therefore it may take a long time to address.

Thanks,

Viet 

0 Kudos
Quinson__Martin
Beginner
1,205 Views

Indeed, we do not compile with the default flags but as follows:

16:15:51 /opt/intel/bin/icpc [...] -fno-common -Wall -Wextra -Wunused
  -Wmissing-declarations -Wcomment -Wformat -Wwrite-strings -Wno-strict-aliasing
  -wd1418 -wd191 -wd3179 -ww597 
  -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function 
  -Wno-unused-parameter -Wno-strict-aliasing -Werror  -g3 -std=gnu++11 -O3 -funroll-loops 
  -fno-strict-aliasing  -fprotect-parens  -fPIC -o [...] -c [...]

(full logs: https://ci.inria.fr/simgrid/job/SimGrid/5937/build_mode=Debug,node=simgrid-fedora26/console )

Our work around is to use PRIdMAX instead of %jd. Commit: https://framagit.org/simgrid/simgrid/commit/819942b4ca0be7a019133420d20004abf80de221

0 Kudos
Reply