[gdal-dev] OGREnvelope: add == and != comparison operators

Andrew C Aitchison andrew at aitchison.me.uk
Wed Feb 23 06:08:01 PST 2022


I am trying to track down numerical errors in my driver code
by turning up all the compiler warnings, but pull request #5122
https://github.com/OSGeo/gdal/pull/5122/commits/3d877aa5da8868ed5c3aacf98845c90bc0d36e54
triggers clang++ -Werror,-Wfloat-equal

Assuming it is possible, would it make sense to tell compilers
(and static analyzers?) to ignore this warning ?

I assume that in this case we *do* want an exact floating point 
comparison.

------------------------------------------------------

clang++-13 -I /usr/local/gdal.git.llvm/include -fPIC -std=c++11 -Wall
 	-Wextra -Weverything -Werror -Wno-padded
 	-Wno-error=unknown-warning-option -Wno-format-pedantic
 	-Wno-c++98-compat-pedantic   -Wno-deprecated-copy-with-dtor
 	-Wno-reserved-identifier -Og -g -DFRMT_qct -DFRMT_qed
 	-c -o qed.o qed.cpp
In file included from qed.cpp:42:
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:60:
In file included from /usr/local/gdal.git.llvm/include/gdal.h:50:
In file included from /usr/local/gdal.git.llvm/include/ogr_api.h:45:
/usr/local/gdal.git.llvm/include/ogr_core.h:158:21: error: comparing 
floating point with == or != is unsafe [-Werror,-Wfloat-equal]
         return MinX == other.MinX &&
                ~~~~ ^  ~~~~~~~~~~
/usr/local/gdal.git.llvm/include/ogr_core.h:159:21: error: comparing 
floating point with == or != is unsafe [-Werror,-Wfloat-equal]
                MinY == other.MinY &&
                ~~~~ ^  ~~~~~~~~~~
/usr/local/gdal.git.llvm/include/ogr_core.h:160:21: error: comparing 
floating point with == or != is unsafe [-Werror,-Wfloat-equal]
                MaxX == other.MaxX &&
                ~~~~ ^  ~~~~~~~~~~
/usr/local/gdal.git.llvm/include/ogr_core.h:161:21: error: comparing 
floating point with == or != is unsafe [-Werror,-Wfloat-equal]
                MaxY == other.MaxY;
                ~~~~ ^  ~~~~~~~~~~
4 errors generated.


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


More information about the gdal-dev mailing list