[petsc-dev] Could you look at this warning?

Barry Smith bsmith at mcs.anl.gov
Tue Mar 1 18:25:52 CST 2016


  I've been ignoring this for a long time. We need to either

1) fscanf into a local int that is 32 bit and then copy it into data but that will produce an incorrect value for very long integers passed in or

2) have an ifdef that uses the correct %lld format when needed, maybe something like

#if PetscInt is long long but %ld refers only to long then
>  else if (dtype == PETSC_INT)     ret = fscanf(fd, "%ld",
> &(((PetscInt*)data)[i]));
#else
>  else if (dtype == PETSC_INT)     ret = fscanf(fd, "%lld",
> &(((PetscInt*)data)[i]));

#endif

  Exact details need to be worked out.

  Barry

> On Mar 1, 2016, at 11:59 AM, Lisandro Dalcin <dalcinl at gmail.com> wrote:
> 
> Barry, sorry to bug you, could take a look? This is Apple clang C++
> with 64 bits indices.
> 
> /Users/dalcinl/Devel/petsc-dev/src/sys/classes/viewer/impls/ascii/filev.c:1054:63:
> warning: format specifies type 'long *' but the argument has type
> 'PetscInt *' (aka 'long long *') [-Wformat]
>    else if (dtype == PETSC_INT)     ret = fscanf(fd, "%ld",
> &(((PetscInt*)data)[i]));
>                                                       ~~~
> ^~~~~~~~~~~~~~~~~~~~~~~
>                                                       %lld
> 1 warning generated.
> 
> 
> -- 
> Lisandro Dalcin
> ============
> Research Scientist
> Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
> Extreme Computing Research Center (ECRC)
> King Abdullah University of Science and Technology (KAUST)
> http://ecrc.kaust.edu.sa/
> 
> 4700 King Abdullah University of Science and Technology
> al-Khawarizmi Bldg (Bldg 1), Office # 4332
> Thuwal 23955-6900, Kingdom of Saudi Arabia
> http://www.kaust.edu.sa
> 
> Office Phone: +966 12 808-0459




More information about the petsc-dev mailing list