OSGeo / grass

GRASS GIS - free and open-source geospatial processing engine
https://grass.osgeo.org
Other
852 stars 309 forks source link

[Bug] GDAL OGR header causes enumerator range pedantic warning #4585

Open wenzeslaus opened 3 weeks ago

wenzeslaus commented 3 weeks ago

Describe the bug

Compilation results in a lot of warnings coming from the include of a GDAL OGR header file with GCC 13 and C GNU 17.

Including gdal/ogr_core.h results in multiple warning: ISO C restricts enumerator values to range of ‘int’ before C2X [-Wpedantic].

To reproduce

This comes from multiple directories, e.g., include/grass/vect. I'm not sure what exact combination of versions and flags is causing this besides the obvious -Wpedantic.

Expected behavior

While the code is external to the project, the compilation output is full of the warnings. It seems that updating to -std=gnu2x solves the issue as the warning suggests, so maybe we can just wait.

Screenshots

In file included from /usr/include/gdal/ogr_api.h:45,
                 from /home/vpetras/Projects/grass/code/grass/dist.x86_64-pc-linux-gnu/include/grass/vect/dig_structs.h:27,
                 from /home/vpetras/Projects/grass/code/grass/dist.x86_64-pc-linux-gnu/include/grass/vect/digit.h:3,
                 from /home/vpetras/Projects/grass/code/grass/dist.x86_64-pc-linux-gnu/include/grass/vector.h:4,
                 from point.c:21:
/usr/include/gdal/ogr_core.h:512:19: warning: ISO C restricts enumerator values to range of ‘int’ before C2X [-Wpedantic]
  512 |     wkbPoint25D = 0x80000001,             /**< 2.5D extension as per 99-402 */
      |                   ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:513:24: warning: ISO C restricts enumerator values to range of ‘int’ before C2X [-Wpedantic]
  513 |     wkbLineString25D = 0x80000002,        /**< 2.5D extension as per 99-402 */
      |                        ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:514:21: warning: ISO C restricts enumerator values to range of ‘int’ before C2X [-Wpedantic]
  514 |     wkbPolygon25D = 0x80000003,           /**< 2.5D extension as per 99-402 */
      |                     ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:515:24: warning: ISO C restricts enumerator values to range of ‘int’ before C2X [-Wpedantic]
  515 |     wkbMultiPoint25D = 0x80000004,        /**< 2.5D extension as per 99-402 */
      |                        ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:516:29: warning: ISO C restricts enumerator values to range of ‘int’ before C2X [-Wpedantic]
  516 |     wkbMultiLineString25D = 0x80000005,   /**< 2.5D extension as per 99-402 */
      |                             ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:517:26: warning: ISO C restricts enumerator values to range of ‘int’ before C2X [-Wpedantic]
  517 |     wkbMultiPolygon25D = 0x80000006,      /**< 2.5D extension as per 99-402 */
      |                          ^~~~~~~~~~
/usr/include/gdal/ogr_core.h:518:32: warning: ISO C restricts enumerator values to range of ‘int’ before C2X [-Wpedantic]
  518 |     wkbGeometryCollection25D = 0x80000007 /**< 2.5D extension as per 99-402 */
      |                                ^~~~~~~~~~
             ^~~~~~~~~~

System description

nilason commented 3 weeks ago

This is reported upstream with https://github.com/OSGeo/gdal/issues/2322. This is circumvented on Mac CI runner with:

https://github.com/OSGeo/grass/blob/cc0fb732328f6f3a0137eddcd937c7c3e2badcab/.github/workflows/macos_install.sh#L64

Unfortunately we also have it in our code:

https://github.com/OSGeo/grass/blob/cc0fb732328f6f3a0137eddcd937c7c3e2badcab/include/grass/vect/dig_defines.h#L254-L260

rouault commented 3 weeks ago

(planned to be addressed in GDAL 3.10 per https://github.com/OSGeo/gdal/pull/11133)