Please re-try with the latest pushed commit in the PR that should hopefully make -Wsign-conversion happy

Le 11/05/2026 à 14:11, Andrew C Aitchison via gdal-dev a écrit :
On Sun, 10 May 2026, Even Rouault wrote:

Andrew,

does https://github.com/OSGeo/gdal/pull/14524 fix the warning?

With that change, clang-tidy is happy, but now the compile breaks if I use
`clang++ -Wsign-conversion`:

In file included from /usr/local/gdal/git.llvm/include/gdal_dataset.h:18:
/usr/local/gdal/git.llvm/include/cpl_port.h:808:33: error: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int')
      [-Werror,-Wsign-conversion]
  808 |         uint32_t unsigned_val = CPL_LSBINT32PTR(x);
      |                  ~~~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~
/usr/local/gdal/git.llvm/include/cpl_port.h:788:62: note: expanded from macro
      'CPL_LSBINT32PTR'
  786 |     ((*CPL_REINTERPRET_CAST(const GByte *, x)) |                     \       | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   787 |      (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 1) << 8) |        \       | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   788 |      (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 2) << 16) |       \       | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
  789 |      (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 3) << 24))
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qed.cpp:122:30: note: in instantiation of function template specialization
      'CPL_LSBSINT32PTR<unsigned char>' requested here
  122 |     return (static_cast<int>(CPL_LSBSINT32PTR(buf)));
      |                              ^



Even

Le 10/05/2026 à 16:02, Andrew C Aitchison via gdal-dev a écrit :

clang-tidy 23 (I'm using Ubuntu 26.04 with build
++20260508083129+d791e3a6f4c8-1~exp1~20260508083148.481
from llvm-toolchain-snapshot at https://www.llvm.org/)
has a new? check bugprone-signed-bitwise.

This check objects to macros like CPL_LSBINT32PTR:

clang-tidy --config="{Checks: 'bugprone-signed-bitwise', CheckOptions: {bugprone-signed-bitwise.IgnorePositiveIntegerLiterals: true}}" frmts/raw/lcpdataset.cpp

reports 63 warnings of [bugprone-signed-bitwise], starting with:

/home/werdna/gdal/git/frmts/raw/lcpdataset.cpp:171:10: warning: use of a signed integer operand with a binary bitwise operator [bugprone-signed-bitwise]
  171 |     if ((CPL_LSBSINT32PTR(poOpenInfo->pabyHeader) != 20 &&
      |          ^
/usr/local/gdal/git.llvm/include/cpl_port.h:799:53: note: expanded from macro 'CPL_LSBSINT32PTR'   799 | #define CPL_LSBSINT32PTR(x) CPL_STATIC_CAST(GInt32, CPL_LSBINT32PTR(x))
      | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/local/gdal/git.llvm/include/cpl_port.h:786:6: note: expanded from macro 'CPL_LSBINT32PTR'   786 |     ((*CPL_REINTERPRET_CAST(const GByte *, x)) |                  \
      |      ^
  787 |      (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 1) << 8U) |    \   788 |      (*((CPL_REINTERPRET_CAST(const GByte *, x)) + 2) << 16U) |   \
|                                                               ~
/usr/local/gdal/git.llvm/include/cpl_port.h:181:55: note: expanded from macro 'CPL_STATIC_CAST'
  181 | #define CPL_STATIC_CAST(type, expr) static_cast<type>(expr)
      | ^~~~

I suspect that default type-promotion from an unsigned GByte
to a *signed* int does not help here.

Not exactly a bug, but annoying.



_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

--
http://www.spatialys.com
My software is free, but my time generally not.

_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to