coin-or / Clp

COIN-OR Linear Programming Solver
Other
396 stars 82 forks source link

Compile error due to wrong format string #172

Closed christoph-cullmann closed 3 years ago

christoph-cullmann commented 3 years ago

Hi,

The code inside ClpPackedMatrix.cpp (this sequence is there twice)

          if(sizeof(CoinBigIndex) == sizeof(int))
            printf("Out of range %d %d %d %g\n", iColumn, j, row[j], elementByColumn[j]);
          else if(sizeof(CoinBigIndex) == sizeof(long))
            printf("Out of range %d %ld %d %g\n", iColumn, j, row[j], elementByColumn[j]);
          else if(sizeof(CoinBigIndex) == sizeof(long long))
            printf("Out of range %d %lld %d %g\n", iColumn, j, row[j], elementByColumn[j]);

leads to errors as the format strings don't fit the type.

I think it would make more sense to just case the j here to the biggest type and avoid the if(....) cascade, e.g.

printf("Out of range %d %lld %d %g\n", iColumn, (long long)j, row[j], elementByColumn[j]);

jjhforrest commented 3 years ago

OK now? (master(

christoph-cullmann commented 3 years ago

Works nicely now here, thanks a lot!