Opened 10 months ago

Last modified 8 months ago

#5558 closed defect

Compilation warning: uninitialized variable — at Version 2

Reported by: Laurenz Albe Owned by: pramsey
Priority: medium Milestone: PostGIS 3.4.1
Component: postgis Version: master
Keywords: Cc:

Description (last modified by Laurenz Albe)

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:

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.

Change History (2)

comment:1 by Laurenz Albe, 10 months ago

Description: modified (diff)

comment:2 by Laurenz Albe, 10 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.