#5558 closed defect (fixed)

Compilation warning: uninitialized variable

Reported by: laurenz Owned by: strk
Priority: medium Milestone: PostGIS 3.4.1
Component: postgis Version: master
Keywords: Cc:

Description (last modified by laurenz)

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 (7)

comment:1 by laurenz, 14 months ago

Description: modified (diff)

comment:2 by laurenz, 14 months ago

Description: modified (diff)

comment:3 by strk, 12 months ago

I guess the intention there was to initialize to zero, judging from the FLAGS_SET_GEODETIC(gbox.flags, 0) which would have no other effects, given the definition of the macro uses bitwise OR… (that line should be replaced by initialization)

comment:4 by strk, 12 months ago

Owner: changed from pramsey to strk
Status: newassigned

comment:5 by Sandro Santilli <strk@…>, 12 months ago

In 0f4ce41/git:

Fix uninizialized variable in MVT

References #5558 in master branch (3.5.0dev)

comment:6 by strk, 12 months ago

I should note that stable-3.3 is already initializing that flag to 0 which was done by paul with [6aa0f6be9f/git]

comment:7 by Sandro Santilli <strk@…>, 12 months ago

Resolution: fixed
Status: assignedclosed

In 161337f/git:

Fix uninizialized variable in MVT

Closes #5558 in 3.4 branch (3.4.1dev)

Note: See TracTickets for help on using tickets.