[gdal-dev] Sign conversion error in ogr_feature.h

Andrew C Aitchison andrew at aitchison.me.uk
Thu May 12 01:22:23 PDT 2022


I fear this should probably go into 3.5.0.

clang++-14 -Wsign-conversion doesn't like the definitions of the new
GetFieldDefnUnsafe() functions

Sorry about the non-line-wrap;
I hope to preserve the 2D intent of the warning messages:

/usr/lib/llvm-14/bin/clang++ -DDONT_DEPRECATE_SPRINTF -DGDAL_CMAKE_BUILD -DGDAL_COMPILATION -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_SSE_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -I/home/werdna/gdal3.5.0/gdal-3.5.0/apps -I/home/werdna/gdal3.5.0/gdal-3.5.0/alg -I/home/werdna/gdal3.5.0/gdal-3.5.0/gcore -I/home/werdna/gdal3.5.0/gdal-3.5.0-llvm/gcore -I/home/werdna/gdal3.5.0/gdal-3.5.0/port -I/home/werdna/gdal3.5.0/gdal-3.5.0-llvm/port -I/home/werdna/gdal3.5.0/gdal-3.5.0/ogr -I/home/werdna/gdal3.5.0/gdal-3.5.0/ogr/ogrsf_frmts -I/home/werdna/gdal3.5.0/gdal-3.5.0/frmts -fvisibility=hidden -g -fPIC -Wsign-conversion -fno-operator-names -Wzero-as-null-pointer-constant -std=gnu++11 -MD -MT ogr/ogrsf_frmts/dxf/CMakeFiles/ogr_DXF.dir/ogrdxf_ocstransformer.cpp.o -MF CMakeFiles/ogr_DXF.dir/ogrdxf_ocstransformer.cpp.o.d -o CMakeFiles/ogr_DXF.dir/ogrdxf_ocstransformer.cpp.o -c /home/werdna/gdal3.5.0/gdal-3.5.0/ogr/ogrsf_frmts/dxf/ogrdxf_ocstransformer.cpp
In file included from /home/werdna/gdal3.5.0/gdal-3.5.0/ogr/ogrsf_frmts/dxf/ogrdxf_ocstransformer.cpp:31:
In file included from /home/werdna/gdal3.5.0/gdal-3.5.0/ogr/ogrsf_frmts/dxf/ogr_dxf.h:35:
In file included from /home/werdna/gdal3.5.0/gdal-3.5.0/ogr/ogrsf_frmts/ogrsf_frmts.h:35:
/home/werdna/gdal3.5.0/gdal-3.5.0/ogr/ogr_feature.h:310:119: warning: implicit conversion changes signedness: 'int' to 'std::vector::size_type' (aka 'unsigned long') [-Wsign-conversion]
     OGRFieldDefn       *GetFieldDefnUnsafe( int i ) { if( apoFieldDefn.empty() ) GetFieldDefn(i); return apoFieldDefn[i].get(); }
                                                                                                          ~~~~~~~~~~~~ ^
/home/werdna/gdal3.5.0/gdal-3.5.0/ogr/ogr_feature.h:311:125: warning: implicit conversion changes signedness: 'int' to 'std::vector::size_type' (aka 'unsigned long') [-Wsign-conversion]
     const OGRFieldDefn *GetFieldDefnUnsafe( int i ) const { if( apoFieldDefn.empty() ) GetFieldDefn(i); return apoFieldDefn[i].get(); }
                                                                                                                ~~~~~~~~~~~~ ^
2 warnings generated.

I think that ogr/ogrfeaturedefn.cpp at least may have to be changed as well.

Is the correct fix to change "int i" to "std::vector::size_type i" ?

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


More information about the gdal-dev mailing list