mapbox / wagyu

A general library for geometry operations of union, intersections, difference, and xor
Other
166 stars 33 forks source link

G++ -Wconversion warnings #74

Closed springmeyer closed 7 years ago

springmeyer commented 7 years ago

We should enable -Wconversion since:

The group of sub-warnings enabled by clang++ are documented at https://clang.llvm.org/docs/DiagnosticsReference.html#wconversion

These are the warning we'll need to fix to be able to enable this option with g++:

g++-4.9 -O3 -DNDEBUG tests/test.cpp tests/unit/*.cpp -Wall -Wextra -Weffc++ -Werror -Wsign-compare -Wfloat-equal -Wconversion -Wshadow  -Iinclude -isystem mason_packages/.link/include -std=c++11 -isystem ./tests -o test
In file included from tests/unit/quick_clip.cpp:4:0:
include/mapbox/geometry/wagyu/quick_clip.hpp: In instantiation of 'mapbox::geometry::point<T> mapbox::geometry::wagyu::quick_clip::intersect(mapbox::geometry::point<T>, mapbox::geometry::point<T>, size_t, const mapbox::geometry::box<T>&) [with T = long int; size_t = long unsigned int]':
include/mapbox/geometry/wagyu/quick_clip.hpp:74:62:   required from 'mapbox::geometry::linear_ring<T> mapbox::geometry::wagyu::quick_clip::quick_lr_clip(const mapbox::geometry::linear_ring<T>&, const mapbox::geometry::box<T>&) [with T = long int]'
tests/unit/quick_clip.cpp:40:75:   required from here
include/mapbox/geometry/wagyu/quick_clip.hpp:21:65: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.x + static_cast<double>(b.x - a.x) * (box.min.y - a.y) / (b.y - a.y)),
                                                                 ^
include/mapbox/geometry/wagyu/quick_clip.hpp:21:85: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.x + static_cast<double>(b.x - a.x) * (box.min.y - a.y) / (b.y - a.y)),
                                                                                     ^
include/mapbox/geometry/wagyu/quick_clip.hpp:21:32: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.x + static_cast<double>(b.x - a.x) * (box.min.y - a.y) / (b.y - a.y)),
                                ^
include/mapbox/geometry/wagyu/quick_clip.hpp:27:65: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.y + static_cast<double>(b.y - a.y) * (box.max.x - a.x) / (b.x - a.x)));
                                                                 ^
include/mapbox/geometry/wagyu/quick_clip.hpp:27:85: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.y + static_cast<double>(b.y - a.y) * (box.max.x - a.x) / (b.x - a.x)));
                                                                                     ^
include/mapbox/geometry/wagyu/quick_clip.hpp:27:32: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.y + static_cast<double>(b.y - a.y) * (box.max.x - a.x) / (b.x - a.x)));
                                ^
include/mapbox/geometry/wagyu/quick_clip.hpp:31:65: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.x + static_cast<double>(b.x - a.x) * (box.max.y - a.y) / (b.y - a.y)),
                                                                 ^
include/mapbox/geometry/wagyu/quick_clip.hpp:31:85: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.x + static_cast<double>(b.x - a.x) * (box.max.y - a.y) / (b.y - a.y)),
                                                                                     ^
include/mapbox/geometry/wagyu/quick_clip.hpp:31:32: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.x + static_cast<double>(b.x - a.x) * (box.max.y - a.y) / (b.y - a.y)),
                                ^
include/mapbox/geometry/wagyu/quick_clip.hpp:37:65: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.y + static_cast<double>(b.y - a.y) * (box.min.x - a.x) / (b.x - a.x)));
                                                                 ^
include/mapbox/geometry/wagyu/quick_clip.hpp:37:85: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.y + static_cast<double>(b.y - a.y) * (box.min.x - a.x) / (b.x - a.x)));
                                                                                     ^
include/mapbox/geometry/wagyu/quick_clip.hpp:37:32: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             static_cast<T>(a.y + static_cast<double>(b.y - a.y) * (box.min.x - a.x) / (b.x - a.x)));
                                ^
In file included from include/mapbox/geometry/wagyu/wagyu.hpp:14:0,
                 from include/mapbox/geometry/wagyu/quick_clip.hpp:6,
                 from tests/unit/quick_clip.cpp:4:
include/mapbox/geometry/wagyu/snap_rounding.hpp: In instantiation of 'bool mapbox::geometry::wagyu::horizontals_at_top_scanbeam(T, mapbox::geometry::wagyu::active_bound_list_itr<T>&, mapbox::geometry::wagyu::active_bound_list<T>&, mapbox::geometry::wagyu::ring_manager<T>&) [with T = long int; mapbox::geometry::wagyu::active_bound_list_itr<T> = __gnu_cxx::__normal_iterator<mapbox::geometry::wagyu::bound<long int>**, std::vector<mapbox::geometry::wagyu::bound<long int>*, std::allocator<mapbox::geometry::wagyu::bound<long int>*> > >; mapbox::geometry::wagyu::active_bound_list<T> = std::vector<mapbox::geometry::wagyu::bound<long int>*, std::allocator<mapbox::geometry::wagyu::bound<long int>*> >]':
include/mapbox/geometry/wagyu/snap_rounding.hpp:111:88:   required from 'void mapbox::geometry::wagyu::process_hot_pixel_edges_at_top_of_scanbeam(T, mapbox::geometry::wagyu::scanbeam_list<T>&, mapbox::geometry::wagyu::active_bound_list<T>&, mapbox::geometry::wagyu::ring_manager<T>&) [with T = long int; mapbox::geometry::wagyu::scanbeam_list<T> = std::vector<long int, std::allocator<long int> >; mapbox::geometry::wagyu::active_bound_list<T> = std::vector<mapbox::geometry::wagyu::bound<long int>*, std::allocator<mapbox::geometry::wagyu::bound<long int>*> >]'
include/mapbox/geometry/wagyu/snap_rounding.hpp:188:96:   required from 'void mapbox::geometry::wagyu::build_hot_pixels(mapbox::geometry::wagyu::local_minimum_list<T>&, mapbox::geometry::wagyu::ring_manager<T>&) [with T = long int; mapbox::geometry::wagyu::local_minimum_list<T> = std::deque<mapbox::geometry::wagyu::local_minimum<long int>, std::allocator<mapbox::geometry::wagyu::local_minimum<long int> > >]'
include/mapbox/geometry/wagyu/wagyu.hpp:128:46:   required from 'bool mapbox::geometry::wagyu::wagyu<T>::execute(mapbox::geometry::wagyu::clip_type, mapbox::geometry::multi_polygon<T2>&, mapbox::geometry::wagyu::fill_type, mapbox::geometry::wagyu::fill_type) [with T2 = long int; T = long int]'
tests/unit/quick_clip.cpp:268:86:   required from here
include/mapbox/geometry/wagyu/snap_rounding.hpp:63:59: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
                 wround<T>((*bnd_next)->current_edge->bot.y) != top_y) {
                                                           ^
include/mapbox/geometry/wagyu/snap_rounding.hpp:62:83: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             if (*bnd_next != nullptr && wround<T>((*bnd_next)->current_edge->top.y) != top_y &&
                                                                                   ^
include/mapbox/geometry/wagyu/snap_rounding.hpp:79:63: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
                     wround<T>((*bnd_prev)->current_edge->bot.y) != top_y) {
                                                               ^
include/mapbox/geometry/wagyu/snap_rounding.hpp:78:87: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
                 if (*bnd_prev != nullptr && wround<T>((*bnd_prev)->current_edge->top.y) != top_y &&
                                                                                       ^
In file included from include/mapbox/geometry/wagyu/build_result.hpp:4:0,
                 from include/mapbox/geometry/wagyu/wagyu.hpp:11,
                 from include/mapbox/geometry/wagyu/quick_clip.hpp:6,
                 from tests/unit/quick_clip.cpp:4:
include/mapbox/geometry/wagyu/ring_util.hpp: In instantiation of 'mapbox::geometry::point<double> mapbox::geometry::wagyu::centroid_of_points(mapbox::geometry::wagyu::point_ptr<T>) [with T = long int; mapbox::geometry::wagyu::point_ptr<T> = mapbox::geometry::wagyu::point<long int>*]':
include/mapbox/geometry/wagyu/ring_util.hpp:810:45:   required from 'mapbox::geometry::wagyu::point_in_polygon_result mapbox::geometry::wagyu::inside_or_outside_special(mapbox::geometry::wagyu::point_ptr<T>, mapbox::geometry::wagyu::point_ptr<T>) [with T = long int; mapbox::geometry::wagyu::point_ptr<T> = mapbox::geometry::wagyu::point<long int>*]'
include/mapbox/geometry/wagyu/ring_util.hpp:847:75:   required from 'bool mapbox::geometry::wagyu::poly2_contains_poly1(mapbox::geometry::wagyu::ring_ptr<T>, mapbox::geometry::wagyu::ring_ptr<T>) [with T = long int; mapbox::geometry::wagyu::ring_ptr<T> = mapbox::geometry::wagyu::ring<long int>*]'
include/mapbox/geometry/wagyu/topology_correction.hpp:1313:50:   required from 'void mapbox::geometry::wagyu::correct_tree(mapbox::geometry::wagyu::ring_manager<T>&) [with T = long int]'
include/mapbox/geometry/wagyu/topology_correction.hpp:1359:25:   required from 'void mapbox::geometry::wagyu::correct_topology(mapbox::geometry::wagyu::ring_manager<T>&) [with T = long int]'
include/mapbox/geometry/wagyu/wagyu.hpp:132:33:   required from 'bool mapbox::geometry::wagyu::wagyu<T>::execute(mapbox::geometry::wagyu::clip_type, mapbox::geometry::multi_polygon<T2>&, mapbox::geometry::wagyu::fill_type, mapbox::geometry::wagyu::fill_type) [with T2 = long int; T = long int]'
tests/unit/quick_clip.cpp:268:86:   required from here
include/mapbox/geometry/wagyu/ring_util.hpp:796:44: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
     return { (prev->x + edge->x + next->x) / 3.0, (prev->y + edge->y + next->y) / 3.0 };
                                            ^
include/mapbox/geometry/wagyu/ring_util.hpp:796:81: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
     return { (prev->x + edge->x + next->x) / 3.0, (prev->y + edge->y + next->y) / 3.0 };
                                                                                 ^
cc1plus: all warnings being treated as errors
In file included from include/mapbox/geometry/wagyu/wagyu.hpp:14:0,
                 from tests/unit/vatti.cpp:5:
include/mapbox/geometry/wagyu/snap_rounding.hpp: In instantiation of 'bool mapbox::geometry::wagyu::horizontals_at_top_scanbeam(T, mapbox::geometry::wagyu::active_bound_list_itr<T>&, mapbox::geometry::wagyu::active_bound_list<T>&, mapbox::geometry::wagyu::ring_manager<T>&) [with T = long int; mapbox::geometry::wagyu::active_bound_list_itr<T> = __gnu_cxx::__normal_iterator<mapbox::geometry::wagyu::bound<long int>**, std::vector<mapbox::geometry::wagyu::bound<long int>*, std::allocator<mapbox::geometry::wagyu::bound<long int>*> > >; mapbox::geometry::wagyu::active_bound_list<T> = std::vector<mapbox::geometry::wagyu::bound<long int>*, std::allocator<mapbox::geometry::wagyu::bound<long int>*> >]':
include/mapbox/geometry/wagyu/snap_rounding.hpp:111:88:   required from 'void mapbox::geometry::wagyu::process_hot_pixel_edges_at_top_of_scanbeam(T, mapbox::geometry::wagyu::scanbeam_list<T>&, mapbox::geometry::wagyu::active_bound_list<T>&, mapbox::geometry::wagyu::ring_manager<T>&) [with T = long int; mapbox::geometry::wagyu::scanbeam_list<T> = std::vector<long int, std::allocator<long int> >; mapbox::geometry::wagyu::active_bound_list<T> = std::vector<mapbox::geometry::wagyu::bound<long int>*, std::allocator<mapbox::geometry::wagyu::bound<long int>*> >]'
include/mapbox/geometry/wagyu/snap_rounding.hpp:188:96:   required from 'void mapbox::geometry::wagyu::build_hot_pixels(mapbox::geometry::wagyu::local_minimum_list<T>&, mapbox::geometry::wagyu::ring_manager<T>&) [with T = long int; mapbox::geometry::wagyu::local_minimum_list<T> = std::deque<mapbox::geometry::wagyu::local_minimum<long int>, std::allocator<mapbox::geometry::wagyu::local_minimum<long int> > >]'
include/mapbox/geometry/wagyu/wagyu.hpp:128:46:   required from 'bool mapbox::geometry::wagyu::wagyu<T>::execute(mapbox::geometry::wagyu::clip_type, mapbox::geometry::multi_polygon<T2>&, mapbox::geometry::wagyu::fill_type, mapbox::geometry::wagyu::fill_type) [with T2 = long int; T = long int]'
tests/unit/vatti.cpp:15:5:   required from here
include/mapbox/geometry/wagyu/snap_rounding.hpp:63:59: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
                 wround<T>((*bnd_next)->current_edge->bot.y) != top_y) {
                                                           ^
include/mapbox/geometry/wagyu/snap_rounding.hpp:62:83: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
             if (*bnd_next != nullptr && wround<T>((*bnd_next)->current_edge->top.y) != top_y &&
                                                                                   ^
include/mapbox/geometry/wagyu/snap_rounding.hpp:79:63: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
                     wround<T>((*bnd_prev)->current_edge->bot.y) != top_y) {
                                                               ^
include/mapbox/geometry/wagyu/snap_rounding.hpp:78:87: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
                 if (*bnd_prev != nullptr && wround<T>((*bnd_prev)->current_edge->top.y) != top_y &&
                                                                                       ^
In file included from include/mapbox/geometry/wagyu/build_result.hpp:4:0,
                 from include/mapbox/geometry/wagyu/wagyu.hpp:11,
                 from tests/unit/vatti.cpp:5:
include/mapbox/geometry/wagyu/ring_util.hpp: In instantiation of 'mapbox::geometry::point<double> mapbox::geometry::wagyu::centroid_of_points(mapbox::geometry::wagyu::point_ptr<T>) [with T = long int; mapbox::geometry::wagyu::point_ptr<T> = mapbox::geometry::wagyu::point<long int>*]':
include/mapbox/geometry/wagyu/ring_util.hpp:810:45:   required from 'mapbox::geometry::wagyu::point_in_polygon_result mapbox::geometry::wagyu::inside_or_outside_special(mapbox::geometry::wagyu::point_ptr<T>, mapbox::geometry::wagyu::point_ptr<T>) [with T = long int; mapbox::geometry::wagyu::point_ptr<T> = mapbox::geometry::wagyu::point<long int>*]'
include/mapbox/geometry/wagyu/ring_util.hpp:847:75:   required from 'bool mapbox::geometry::wagyu::poly2_contains_poly1(mapbox::geometry::wagyu::ring_ptr<T>, mapbox::geometry::wagyu::ring_ptr<T>) [with T = long int; mapbox::geometry::wagyu::ring_ptr<T> = mapbox::geometry::wagyu::ring<long int>*]'
include/mapbox/geometry/wagyu/topology_correction.hpp:1313:50:   required from 'void mapbox::geometry::wagyu::correct_tree(mapbox::geometry::wagyu::ring_manager<T>&) [with T = long int]'
include/mapbox/geometry/wagyu/topology_correction.hpp:1359:25:   required from 'void mapbox::geometry::wagyu::correct_topology(mapbox::geometry::wagyu::ring_manager<T>&) [with T = long int]'
include/mapbox/geometry/wagyu/wagyu.hpp:132:33:   required from 'bool mapbox::geometry::wagyu::wagyu<T>::execute(mapbox::geometry::wagyu::clip_type, mapbox::geometry::multi_polygon<T2>&, mapbox::geometry::wagyu::fill_type, mapbox::geometry::wagyu::fill_type) [with T2 = long int; T = long int]'
tests/unit/vatti.cpp:15:5:   required from here
include/mapbox/geometry/wagyu/ring_util.hpp:796:44: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
     return { (prev->x + edge->x + next->x) / 3.0, (prev->y + edge->y + next->y) / 3.0 };
                                            ^
include/mapbox/geometry/wagyu/ring_util.hpp:796:81: error: conversion to 'double' from 'long int' may alter its value [-Werror=conversion]
     return { (prev->x + edge->x + next->x) / 3.0, (prev->y + edge->y + next->y) / 3.0 };
                                                                                 ^
cc1plus: all warnings being treated as errors
make: *** [build-test] Error 1
flippmoke commented 7 years ago

Still having issues with g++-6