Opened 7 years ago

Closed 3 years ago

#5978 closed defect (wontfix)

ogr_core.h <- 32 bit compatibility

Reported by: mkuhn Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

Building QGIS produces the following warning (among similar):

/.../QGIS/src/providers/ogr/qgsogrprovider.cpp:583:10: warning: case value evaluates to 2147483655, which cannot be narrowed to type 'int' [-Wc++11-narrowing]

    case wkbGeometryCollection25D: geom = "GeometryCollection25D"; break;

As far as I understand this is caused by an enum which contains values which will result in an integer overflow on 32bit systems:

/**
 * List of well known binary geometry types.  These are used within the BLOBs
 * but are also returned from OGRGeometry::getGeometryType() to identify the
 * type of a geometry object.
 */
typedef enum 
{
    wkbUnknown = 0,         /**< unknown type, non-standard */
    wkbPoint = 1,           /**< 0-dimensional geometric object, standard WKB */
    wkbLineString = 2,      /**< 1-dimensional geometric object with linear
                             *   interpolation between Points, standard WKB */
    wkbPolygon = 3,         /**< planar 2-dimensional geometric object defined
                             *   by 1 exterior boundary and 0 or more interior
                             *   boundaries, standard WKB */
    wkbMultiPoint = 4,      /**< GeometryCollection of Points, standard WKB */
    wkbMultiLineString = 5, /**< GeometryCollection of LineStrings, standard WKB */
    wkbMultiPolygon = 6,    /**< GeometryCollection of Polygons, standard WKB */
    wkbGeometryCollection = 7, /**< geometric object that is a collection of 1
                                    or more geometric objects, standard WKB */
    wkbNone = 100,          /**< non-standard, for pure attribute records */
    wkbLinearRing = 101,    /**< non-standard, just for createGeometry() */
    wkbPoint25D = 0x80000001, /**< 2.5D extension as per 99-402 */
    wkbLineString25D = 0x80000002, /**< 2.5D extension as per 99-402 */
    wkbPolygon25D = 0x80000003, /**< 2.5D extension as per 99-402 */
    wkbMultiPoint25D = 0x80000004, /**< 2.5D extension as per 99-402 */
    wkbMultiLineString25D = 0x80000005, /**< 2.5D extension as per 99-402 */
    wkbMultiPolygon25D = 0x80000006, /**< 2.5D extension as per 99-402 */
    wkbGeometryCollection25D = 0x80000007 /**< 2.5D extension as per 99-402 */
} OGRwkbGeometryType;

Would it hurt to lower these values so they are in the range of a 32-bit integer?

Change History (2)

comment:1 Changed 7 years ago by Even Rouault

This is part of the ABI. Hum, this is something we should perhaps have done during 2.0 dev cycle but I was somewhat hesitant. There's also a link with the wkbHasZ() macro that does a bitwise and with 0x80000000 Generally doing switch ( (int)geom_type ) { } fixes the warning (but at the expense of not being warned about missing cases, and there are new values in 2.0)

comment:2 Changed 3 years ago by Even Rouault

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub?. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.