[QGIS-Developer] bare isnan -- why isn't CI catching this?

Alessandro Pasotti apasotti at gmail.com
Fri Jan 26 06:51:00 PST 2024


I think the answer is here (emphasis on "an implementation is allowed
but not required to bring those functions into the global namespace")
: https://stackoverflow.com/questions/18128899/is-isnan-in-the-std-namespace-more-in-general-when-is-std-necessary-optio

In other words, it should be prefixed with std::, I agree this should
be tested in CI (but I don't know how).


On Fri, Jan 26, 2024 at 3:06 PM Greg Troxel via QGIS-Developer
<qgis-developer at lists.osgeo.org> wrote:
>
> I am in the process of building 3.34.3 for pkgsrc.  (We've been on 3.28.x,
> and I am just now getting to jumping to the new LTR.)
>
> I am using gcc 7.5.0 on NetBSD 10 amd64.
>
> I found a case of bare isnan in a source file.  It's easy for me to
> patch to std::isnan.  I see that there are a large number of std::isnan
> in the sources.  I am guessing that formally bare isnan is an error, but
> have not passed the bar to be a practicing C++ Language Lawyer.   I see
> an include of cmath, but not "use that scope as if here" decl.
>
> My question is:
>
>   Is it in fact invalid code to use bare isnan instead of std::isnan, vs
>   would someone claim my compiler is wrong?
>
>   Assuming bare isnan is wrong, why isn't qgis's CI catching this?  I
>   would think the CI environment should have the equivalent of
>   POSIXLY_CORRECT to try to reject as much as possible in terms of using
>   extensions not required by standards.
>
> [ 56%] Building CXX object src/core/CMakeFiles/qgis_core.dir/raster/qgsrasterattributetable.cpp.o
> /tmp/work/wip/qgis/work/qgis-3.34.3/src/core/raster/qgsrasterattributetable.cpp: In member function 'QgsGradientColorRamp QgsRasterAttributeTable::colorRamp(QStringList&, int) const':
> /tmp/work/wip/qgis/work/qgis-3.34.3/src/core/raster/qgsrasterattributetable.cpp:1362:16: error: 'isnan' was not declared in this scope; did you mean 'std::isnan'?
>  1362 |         if ( ! isnan( min ) && ! isnan( max ) )
>       |                ^~~~~
>       |                std::isnan
> In file included from /tmp/work/wip/qgis/work/qgis-3.34.3/src/core/qgis.h:25,
>                  from /tmp/work/wip/qgis/work/qgis-3.34.3/src/core/qgsfield.h:25,
>                  from /tmp/work/wip/qgis/work/qgis-3.34.3/src/core/qgsfields.h:22,
>                  from /tmp/work/wip/qgis/work/qgis-3.34.3/src/core/raster/qgsrasterattributetable.h:19,
>                  from /tmp/work/wip/qgis/work/qgis-3.34.3/src/core/raster/qgsrasterattributetable.cpp:17:
> /usr/include/g++/cmath:632:5: note: 'std::isnan' declared here
>   632 |     isnan(_Tp __x)
>       |     ^~~~~
> gmake[2]: *** [src/core/CMakeFiles/qgis_core.dir/build.make:10842: src/core/CMakeFiles/qgis_core.dir/raster/qgsrasterattributetable.cpp.o] Error 1
> gmake[2]: Target 'src/core/CMakeFiles/qgis_core.dir/build' not remade because of errors.
> gmake[1]: *** [CMakeFiles/Makefile2:4912: src/core/CMakeFiles/qgis_core.dir/all] Error 2
> gmake[1]: Target 'all' not remade because of errors.
> gmake: *** [Makefile:166: all] Error 2
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer



-- 
Alessandro Pasotti
QCooperative:  www.qcooperative.net
ItOpen:   www.itopen.it


More information about the QGIS-Developer mailing list