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

Even Rouault even.rouault at spatialys.com
Thu May 12 01:53:28 PDT 2022


Andrew,

Le 12/05/2022 à 10:22, Andrew C Aitchison a écrit :
>
> I fear this should probably go into 3.5.0.
Althoug annoying, this is just a warning. I see this is as a 3.5.1 
material, otherwise 3.5.0 will never be released.
>
> 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" ?
Fix queued in https://github.com/OSGeo/gdal/pull/5712 (I didn't change 
the signature, but the[] access, so it is the same as other similar methods)

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



More information about the gdal-dev mailing list