mapbox / tippecanoe

Build vector tilesets from large collections of GeoJSON features.
BSD 2-Clause "Simplified" License
2.74k stars 432 forks source link

Compiler warning under gcc 11.3.0 ubuntu-22.04 #957

Open mvl22 opened 2 years ago

mvl22 commented 2 years ago

make -j on ubuntu-22.04 (gcc version 11.3.0) includes output:

g++  -L/usr/local/lib -g -Wall -Wshadow -Wsign-compare -Wextra -Wunreachable-code -Wuninitialized -Wshadow -O3 -DNDEBUG  -std=c++11 -o tippecanoe-enumerate enumerate.o  -lsqlite3
tile.cpp: In function ‘bool find_common_edges(std::vector<partial>&, int, int, double, int, double)’:
tile.cpp:751:140: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘long int:40’ [-Wformat=]
  751 |                                                                         fprintf(stderr, "Internal error: polygon edge lookup failed for %lld,%lld to %lld,%lld or %lld,%lld to %lld,%lld\n", left[0].x, left[0].y, left[1].x, left[1].y, right[0].x, right[0].y, right[1].x, right[1].y);
      |                                                                                                                                         ~~~^
      |                                                                                                                                            |
      |                                                                                                                                            long long int
tile.cpp:751:145: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘long int:40’ [-Wformat=]
  751 |                                                                         fprintf(stderr, "Internal error: polygon edge lookup failed for %lld,%lld to %lld,%lld or %lld,%lld to %lld,%lld\n", left[0].x, left[0].y, left[1].x, left[1].y, right[0].x, right[0].y, right[1].x, right[1].y);
      |                                                                                                                                              ~~~^
      |                                                                                                                                                 |
      |                                                                                                                                                 long long int
tile.cpp:751:153: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 5 has type ‘long int:40’ [-Wformat=]
  751 |                                                                         fprintf(stderr, "Internal error: polygon edge lookup failed for %lld,%lld to %lld,%lld or %lld,%lld to %lld,%lld\n", left[0].x, left[0].y, left[1].x, left[1].y, right[0].x, right[0].y, right[1].x, right[1].y);
      |                                                                                                                                                      ~~~^
      |                                                                                                                                                         |
      |                                                                                                                                                         long long int
tile.cpp:751:158: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 6 has type ‘long int:40’ [-Wformat=]
  751 |                                                                         fprintf(stderr, "Internal error: polygon edge lookup failed for %lld,%lld to %lld,%lld or %lld,%lld to %lld,%lld\n", left[0].x, left[0].y, left[1].x, left[1].y, right[0].x, right[0].y, right[1].x, right[1].y);
      |                                                                                                                                                           ~~~^
      |                                                                                                                                                              |
      |                                                                                                                                                              long long int
tile.cpp:751:166: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 7 has type ‘long int:40’ [-Wformat=]
  751 |                                                                         fprintf(stderr, "Internal error: polygon edge lookup failed for %lld,%lld to %lld,%lld or %lld,%lld to %lld,%lld\n", left[0].x, left[0].y, left[1].x, left[1].y, right[0].x, right[0].y, right[1].x, right[1].y);
      |                                                                                                                                                                   ~~~^
      |                                                                                                                                                                      |
      |                                                                                                                                                                      long long int
tile.cpp:751:171: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 8 has type ‘long int:40’ [-Wformat=]
  751 |                                                                         fprintf(stderr, "Internal error: polygon edge lookup failed for %lld,%lld to %lld,%lld or %lld,%lld to %lld,%lld\n", left[0].x, left[0].y, left[1].x, left[1].y, right[0].x, right[0].y, right[1].x, right[1].y);
      |                                                                                                                                                                        ~~~^
      |                                                                                                                                                                           |
      |                                                                                                                                                                           long long int
tile.cpp:751:179: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 9 has type ‘long int:40’ [-Wformat=]
  751 |                                                                         fprintf(stderr, "Internal error: polygon edge lookup failed for %lld,%lld to %lld,%lld or %lld,%lld to %lld,%lld\n", left[0].x, left[0].y, left[1].x, left[1].y, right[0].x, right[0].y, right[1].x, right[1].y);
      |                                                                                                                                                                                ~~~^
      |                                                                                                                                                                                   |
      |                                                                                                                                                                                   long long int
tile.cpp:751:184: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 10 has type ‘long int:40’ [-Wformat=]
  751 |                                                                         fprintf(stderr, "Internal error: polygon edge lookup failed for %lld,%lld to %lld,%lld or %lld,%lld to %lld,%lld\n", left[0].x, left[0].y, left[1].x, left[1].y, right[0].x, right[0].y, right[1].x, right[1].y);
      |                                                                                                                                                                                     ~~~^
      |                                                                                                                                                                                        |
      |                                                                                                                                                                                        long long int
geometry.cpp: In function ‘drawvec clean_or_clip_poly(drawvec&, int, int, bool)’:
geometry.cpp:301:65: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘long int:40’ [-Wformat=]
  301 |                                                 fprintf(f, "[%lld,%lld]", geom[k].x, geom[k].y);
      |                                                              ~~~^
      |                                                                 |
      |                                                                 long long int
geometry.cpp:301:70: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘long int:40’ [-Wformat=]
  301 |                                                 fprintf(f, "[%lld,%lld]", geom[k].x, geom[k].y);
      |                                                                   ~~~^
      |                                                                      |
      |                                                                      long long int
geometry.cpp: In function ‘void check_polygon(drawvec&)’:
geometry.cpp:419:68: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘long int:40’ [-Wformat=]
  419 |                                                         printf("%lld,%lld at %lld not in outer ring (%lld to %lld)\n", geom[k].x, geom[k].y, (long long) k, (long long) outer_start, (long long) (outer_start + outer_len));
      |                                                                 ~~~^
      |                                                                    |
      |                                                                    long long int
geometry.cpp:419:73: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘long int:40’ [-Wformat=]
  419 |                                                         printf("%lld,%lld at %lld not in outer ring (%lld to %lld)\n", geom[k].x, geom[k].y, (long long) k, (long long) outer_start, (long long) (outer_start + outer_len));
      |                                                                      ~~~^
      |                                                                         |
      |                                                                         long long int
geometry.cpp: In function ‘drawvec reduce_tiny_poly(drawvec&, int, int, bool*, double*)’:
geometry.cpp:586:56: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘long int:40’ [-Wformat=]
  586 |                                 fprintf(stderr, "%d/%lld/%lld ", geom[n].op, geom[n].x, geom[n].y);
      |                                                     ~~~^
      |                                                        |
      |                                                        long long int
geometry.cpp:586:61: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 5 has type ‘long int:40’ [-Wformat=]
  586 |                                 fprintf(stderr, "%d/%lld/%lld ", geom[n].op, geom[n].x, geom[n].y);
      |                                                          ~~~^
      |                                                             |
      |                                                             long long int
g++  -L/usr/local/lib -g -Wall -Wshadow -Wsign-compare -Wextra -Wunreachable-code -Wuninitialized -Wshadow -O3 -DNDEBUG  -std=c++11 -o tippecanoe-json-tool jsontool.o jsonpull/jsonpull.o csv.o text.o geojson-loop.o  -lm -lz -lsqlite3 -lpthread
e-n-f commented 2 years ago

Thanks, I will look into this in https://github.com/felt/tippecanoe.

e-n-f commented 2 years ago

x and y are declared as long long bitfields:

struct draw {
        long long x : 40;
        signed char op;
        long long y : 40;
        signed char necessary;
        …
};

so I would expect them to remain long long for printf purposes, not to be de-promoted to long, but I will add some casts to make gcc happy.

e-n-f commented 2 years ago

x and y are declared as long long bitfields:

struct draw {
        long long x : 40;
        signed char op;
        long long y : 40;
        signed char necessary;
        …
};

so I would expect them to remain long long for printf purposes, not to be de-promoted to long, but I will add some casts to make gcc happy.