[gdal-dev] OGRFeatureDefn and clang -Wsign-conversion

Andrew C Aitchison andrew at aitchison.me.uk
Wed Dec 7 09:12:23 PST 2022


https://github.com/OSGeo/gdal/commit/b0797370a3ed238bc5e74435262c2e889f58fe03
adds two new classes GetFields() and GetGeomFields() for easier C++ iteration.

Unfortunately clang++ -Wsign-conversion is unhappy about the implicit
change of signedness in the size() functions of these classes:

clang++-15 -fPIC -std=c++11 -I/usr/local/gdal/git.llvm/include -g -O3
   -DFRMT_VRC -DVRC_STANDALONE -std=c++11 -Wsign-conversion -c -o VRC.o VRC.cpp
In file included from VRC.cpp:38:
In file included from ./VRC.h:56:
In file included from /usr/local/gdal/git.llvm/include/gdal_pam.h:36:
In file included from /usr/local/gdal/git.llvm/include/gdal_priv.h:81:
/usr/local/gdal/git.llvm/include/ogr_feature.h:336:56: warning: implicit
    conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long')
    [-Wsign-conversion]
         inline size_t size() const { return m_poFDefn->GetFieldCount(); }
                                      ~~~~~~ ~~~~~~~~~~~^~~~~~~~~~~~~~~
/usr/local/gdal/git.llvm/include/ogr_feature.h:403:56: warning: implicit
    conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long')
    [-Wsign-conversion]
         inline size_t size() const { return m_poFDefn->GetGeomFieldCount(); }
                                      ~~~~~~ ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
2 warnings generated.

The obvious static_cast seems to work but I am not sure
whether that is fixing the issue or just hiding it.

Draft pull request at
 	https://github.com/OSGeo/gdal/pull/6869

-- 
Andrew C. Aitchison                      Kendal, UK
                    andrew at aitchison.me.uk


More information about the gdal-dev mailing list