[postgis-tickets] [PostGIS] #5558: Compilation warning: uninitialized variable
PostGIS
trac at osgeo.org
Fri Sep 29 05:24:10 PDT 2023
#5558: Compilation warning: uninitialized variable
---------------------------+---------------------------
Reporter: Laurenz Albe | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 3.4.1
Component: postgis | Version: master
Resolution: | Keywords:
---------------------------+---------------------------
Description changed by Laurenz Albe:
Old description:
> Building master, I get
>
> {{{
> In file included from mvt.h:40,
> from mvt.c:30:
> mvt.c: In function ‘mvt_clip_and_validate_geos’:
> mvt.c:884:41: warning: ‘bgbox.flags’ may be used uninitialized [-Wmaybe-
> uninitialized]
> 884 | FLAGS_SET_GEODETIC(bgbox.flags, 0);
> ../liblwgeom/liblwgeom.h:175:95: note: in definition of macro
> ‘FLAGS_SET_GEODETIC’
> 175 | #define FLAGS_SET_GEODETIC(flags, value) ((flags) = (value) ?
> ((flags) | LWFLAG_GEODETIC) : ((flags) & ~LWFLAG_GEODETIC))
> |
> ^~~~~
> mvt.c:881:22: note: ‘bgbox’ declared here
> 881 | GBOX bgbox;
> | ^~~~~
> }}}
>
> Indeed, in `postgis/mvt.c`, `bgbox.flag` is not initialized:
>
> {{{#!c
> GBOX bgbox;
> bgbox.xmax = bgbox.ymax = (double)extent + (double)buffer;
> bgbox.xmin = bgbox.ymin = -(double)buffer;
> FLAGS_SET_GEODETIC(bgbox.flags, 0);
> }}}
>
> I cannot suggest a patch, because I don't know to what value the `flags`
> should be initialized.
New description:
Building master, I get
{{{
In file included from mvt.h:40,
from mvt.c:30:
mvt.c: In function ‘mvt_clip_and_validate_geos’:
mvt.c:884:41: warning: ‘bgbox.flags’ may be used uninitialized [-Wmaybe-
uninitialized]
884 | FLAGS_SET_GEODETIC(bgbox.flags, 0);
../liblwgeom/liblwgeom.h:175:95: note: in definition of macro
‘FLAGS_SET_GEODETIC’
175 | #define FLAGS_SET_GEODETIC(flags, value) ((flags) = (value) ?
((flags) | LWFLAG_GEODETIC) : ((flags) & ~LWFLAG_GEODETIC))
|
^~~~~
mvt.c:881:22: note: ‘bgbox’ declared here
881 | GBOX bgbox;
| ^~~~~
}}}
Indeed, in `postgis/mvt.c`, `bgbox.flags` is not initialized:
{{{#!c
GBOX bgbox;
bgbox.xmax = bgbox.ymax = (double)extent + (double)buffer;
bgbox.xmin = bgbox.ymin = -(double)buffer;
FLAGS_SET_GEODETIC(bgbox.flags, 0);
}}}
I cannot suggest a patch, because I don't know to what value the `flags`
should be initialized.
--
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5558#comment:2>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list