Merge pull request #4514 from MaelRL/CGAL-Fix_warnings-GF

Fix (some) testuite warnings
This commit is contained in:
Sebastien Loriot 2020-04-16 18:15:11 +02:00 committed by GitHub
commit 98fafe4ef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 94 additions and 98 deletions

View File

@ -39,7 +39,7 @@ public:
typedef typename Algebraic_kernel_d_1::Algebraic_real_1 Algebraic_real_1;
Bitstream_coefficient_kernel_at_alpha_rep() {}
Bitstream_coefficient_kernel_at_alpha_rep() : _m_kernel(nullptr) {}
Bitstream_coefficient_kernel_at_alpha_rep(Algebraic_kernel_d_1* kernel,
Algebraic_real_1 alpha)

View File

@ -41,11 +41,11 @@ int main()
int n;
is >> n;
std::cout << "Reading " << n << " points " << std::endl;
Bare_point bp;
for( ; n>0 ; n--) {
is >> bp;
Weighted_point p(bp, 0.0001 * random.get_double(0., 0.015625)); // arbitrary weights
pts.push_back(p);
for( ; n>0 ; n--)
{
Bare_point bp;
if(is >> bp)
pts.emplace_back(bp, 0.0001 * random.get_double(0., 0.015625)); // arbitrary weights
}
// Define the periodic cube

View File

@ -60,7 +60,7 @@ private:
void Cone_spanners_ipelet::protected_run(int fn)
{
std::vector<Point_2> lst;
int number_of_cones;
int number_of_cones = 0;
switch (fn){
case 0:
case 1:

View File

@ -312,15 +312,12 @@ class ConicCPA2
PT center () const
{
CGAL_kernel_precondition (type != PARABOLA);
// PT p;
// replaced previous line by following hack (no idea
// why original version doesn't work)
typename DA::Point p;
FT two = FT(2);
FT div = -det();
dao.set( p, (two*s()*u() - t()*v()) / div,
(two*r()*v() - t()*u()) / div);
return p;
const FT two = FT(2);
const FT div = -det();
return PT((two*s()*u() - t()*v()) / div,
(two*r()*v() - t()*u()) / div);
}
Conic_type conic_type () const

View File

@ -268,6 +268,13 @@ line_y_at_xC2(const FT &a, const FT &b, const FT &c, const FT &x)
return (-a*x-c) / b;
}
// Silence a warning for MSVC 2017
// > include\cgal\constructions\kernel_ftc2.h(287) :
// > warning C4723: potential divide by 0
#if defined(BOOST_MSVC)
#pragma warning(push)
#pragma warning(disable:4723)
#endif
template < class FT >
inline
void
@ -276,14 +283,6 @@ line_get_pointC2(const FT &a, const FT &b, const FT &c, const FT &i,
{
if (CGAL_NTS is_zero(b))
{
// Laurent Rineau, 2018/12/07: I add this CGAL_assume to calm
// down a warning from MSVC 2017:
// > include\cgal\constructions\kernel_ftc2.h(287) :
// > warning C4723: potential divide by 0
// The test `!boost::is_integral<FT>::value` is there to avoid
// that `a != 0` is tested on anything but integral types, for
// performance reasons.
CGAL_assume(!boost::is_integral<FT>::value || a != FT(0));
x = -c/a;
y = 1 - i * a;
@ -294,6 +293,9 @@ line_get_pointC2(const FT &a, const FT &b, const FT &c, const FT &i,
y = -(a+c)/b - i * a;
}
}
#if defined(BOOST_MSVC)
#pragma warning(pop)
#endif
template < class FT >
inline

View File

@ -822,8 +822,7 @@ locate(const Point_d& x) const
lifted_kernel().lift_to_paraboloid_d_object();;
Lifted_point_d lp = lift(x);
if ( is_dimension_jump(lp) ) {
Simplex_iterator s;
for (s = const_cast<Self*>(this)->simplices_begin(NEAREST);
for (Simplex_iterator s = const_cast<Self*>(this)->simplices_begin(NEAREST);
s != const_cast<Self*>(this)->simplices_end(); ++s)
if ( contains(s,x) ) return s;
return Simplex_handle();

View File

@ -79,9 +79,15 @@ int main()
Convex_hull_d::Point_const_iterator pit;
Convex_hull_d::Vertex_iterator vit;
Convex_hull_d::Simplex_iterator sit;
for (pit = T1.points_begin(); pit != T1.points_end(); pit++) *pit;
for (vit = T1.vertices_begin(); vit != T1.vertices_end(); vit++) *vit;
for (sit = T1.simplices_begin(); sit != T1.simplices_end(); sit++) *sit;
for (pit = T1.points_begin(); pit != T1.points_end(); pit++) {
const Point& p = *pit;
CGAL_USE(p);
}
for (vit = T1.vertices_begin(); vit != T1.vertices_end(); vit++)
*vit;
for (sit = T1.simplices_begin(); sit != T1.simplices_end(); sit++)
*sit;
T1.is_valid();
T1.clear(2);
CGAL_TEST(T1.number_of_vertices()==0);

View File

@ -41,7 +41,8 @@ fct(const P& )
{
std::map<Descriptor,int> M;
Descriptor d;
M.find(d);
typename std::map<Descriptor,int>::const_iterator it = M.find(d);
CGAL_USE(it);
boost::unordered_map<Descriptor, int> U;
U[d] = 12;
@ -56,7 +57,9 @@ void fct2()
{ // For dart handle
std::map<dh, int> M;
dh e;
M.find(e);
typename std::map<dh, int>::const_iterator it = M.find(e);
CGAL_USE(it);
boost::unordered_map<dh, int> U;
U[e] = 12;
}
@ -64,7 +67,9 @@ void fct2()
{ // For vertex attribute handle
std::map<vh, int> M;
vh e;
M.find(e);
typename std::map<vh, int>::const_iterator it = M.find(e);
CGAL_USE(it);
boost::unordered_map<vh, int> U;
U[e] = 12;
}

View File

@ -310,13 +310,8 @@ class ConicHPA2
PT center () const
{
CGAL_kernel_precondition (type != PARABOLA);
// PT p;
// replaced previous line by following hack (no idea
// why original version doesn't work)
typename DA::Point_2 p;
RT two = RT(2);
dao.set( p, two*s()*u() - t()*v(), two*r()*v() - t()*u(), -det());
return p;
return PT(two*s()*u() - t()*v(), two*r()*v() - t()*u(), -det());
}
Conic_type conic_type () const

View File

@ -1373,7 +1373,6 @@ private:
std::size_t vertex_id(const std::size_t& i) const
{
CGAL_precondition(i >= 0);
CGAL_precondition((infinite_ && i < 3) || i < 4);
return vertices_[i];
}

View File

@ -540,8 +540,13 @@ public:
Mark m[2];
Object_handle o_supp[2];
SHalfedge_handle e_below;
vertex_info()
{ o_supp[0]=o_supp[1]=Object_handle(); }
{
m[0]=m[1]=Mark();
o_supp[0]=o_supp[1]=Object_handle();
}
LEDA_MEMORY(vertex_info)
}; // vertex_info

View File

@ -91,12 +91,14 @@ void test_lazy_exact_nt() {
assert( cast ( (i*i+i) / i-i ) == LR(1));
assert( cast ( (i*i+r) / i-i ) == LR(1));
assert( cast ( (i*r+r) / i-i ) == LI(1));
}{ // see also Coercion_traits_test.C
}
{ // see also Coercion_traits_test.C
#ifdef CGAL_USE_LEDA
#ifdef CGAL_USE_CORE
typedef CGAL::Lazy_exact_nt<leda_integer > T1;
typedef CGAL::Lazy_exact_nt<CORE::Expr > T2;
typedef CGAL::Coercion_traits<T1,T2> CT;
CGAL_assertion_code(typedef CGAL::Lazy_exact_nt<leda_integer> T1;)
CGAL_assertion_code(typedef CGAL::Lazy_exact_nt<CORE::Expr> T2;)
CGAL_assertion_code(typedef CGAL::Coercion_traits<T1, T2> CT;)
CGAL_static_assertion((boost::is_same< typename CT::Are_implicit_interoperable,CGAL::Tag_false>::value));
CGAL_static_assertion((boost::is_same< typename CT::Are_explicit_interoperable,CGAL::Tag_false>::value));
#endif

View File

@ -147,10 +147,8 @@ update_new_point(
typedef typename rich_grid_internal::Rich_point<Kernel> Rich_point;
CGAL_assertion_code( unsigned int size = static_cast<unsigned int>(rich_point_set.size()) );
CGAL_point_set_processing_precondition(father_index >= 0 &&
father_index < size);
CGAL_point_set_processing_precondition(mother_index >= 0 &&
mother_index < size);
CGAL_point_set_processing_precondition(father_index < size);
CGAL_point_set_processing_precondition(mother_index < size);
// 1, get neighbor information from the two "parent points"
Rich_point& new_v = rich_point_set[new_point_index];

View File

@ -50,7 +50,12 @@ class My_vertex : public CGAL::HalfedgeDS_vertex_base<Refs, T, P> {
Norm norm;
public:
My_vertex() {} // repeat mandatory constructors
My_vertex( const P& pt) : CGAL::HalfedgeDS_vertex_base<Refs, T, P>(pt) {}
My_vertex( const P& pt)
: CGAL::HalfedgeDS_vertex_base<Refs, T, P>(pt)
{
//initialization of the normal
norm= CGAL::NULL_VECTOR;
}
typedef Norm Normal_3;
Normal_3& normal() { return norm; }
const Normal_3& normal() const { return norm; }

View File

@ -207,9 +207,6 @@ MainWindow::MainWindow()
this->addRecentFiles(this->menuFile, this->actionQuit);
connect(this, SIGNAL(openRecentFile(QString)), this, SLOT(open(QString)));
// QObject::connect(thresholdSlider, SIGNAL(valueChanged(int)), this, SLOT(set_Threshold(int)));
}

View File

@ -279,14 +279,6 @@
<include location="../icons/Triangulation_2.qrc" />
<include location="../icons/Input.qrc" />
</resources>
<connections>
<connection>
<sender>thresholdSlider</sender>
<signal>valueChanged(int)</signal>
<receiver>MainWindow</receiver>
<slot>setThreshold(int)</slot>
</connection>
</connections>
<slots>
<slot>setThreshold(int)</slot>
</slots>

View File

@ -109,7 +109,7 @@ Polynomial<NT> modular_gcd_utcf_algorithm_M(
MScalar mg_;
MPoly mF1,mF2,mG_;
typename CRT::Scalar_type p,q,pq,s,t;
typename CRT::Scalar_type p(0),q(0),pq,s,t;
Poly Gs,H1s,H2s, Gs_old; // s =^ star
#ifdef CGAL_MODULAR_GCD_TIMER
timer_init.stop();

View File

@ -27,9 +27,11 @@ int main()
CGAL::cpp0x::copy_n(arr.begin(), 3, arr2.begin());
std::copy_n(arr.begin(), 3, arr2.begin());
CGAL::cpp0x::prev(arr.end());
std::prev(arr.end());
CGAL::cpp0x::next(arr.begin());
std::next(arr.begin());
CGAL::cpp0x::array<int, 3>::iterator it = CGAL::cpp0x::prev(arr.end());
it = std::prev(arr.end());
it = CGAL::cpp0x::next(arr.begin());
it = std::next(arr.begin());
CGAL_USE(it);
return 0;
}

View File

@ -246,11 +246,11 @@ public:
if ( t.is_segment() ) {
Point_handle_pair php =
this->register_input_site(t.source(), t.target());
this->register_input_site(t.source_of_supporting_site(), t.target_of_supporting_site());
Storage_site_2 ss =
this->st_.construct_storage_site_2_object()(php.first, php.second);
Vertex_handle v =
insert_segment(t.source(), t.target(), ss, UNDEFINED_LEVEL);
insert_segment(t.source_of_supporting_site(), t.target_of_supporting_site(), ss, UNDEFINED_LEVEL);
if ( v == Vertex_handle() ) {
this->unregister_input_site( php.first, php.second );
}
@ -282,12 +282,12 @@ public:
if ( t.is_segment() ) {
Point_handle_pair php =
this->register_input_site(t.source(), t.target());
this->register_input_site(t.source_of_supporting_site(), t.target_of_supporting_site());
Storage_site_2 ss =
this->st_.construct_storage_site_2_object()(php.first, php.second);
ss.set_info(info);
Vertex_handle v =
insert_segment(t.source(), t.target(), ss, UNDEFINED_LEVEL);
insert_segment(t.source_of_supporting_site(), t.target_of_supporting_site(), ss, UNDEFINED_LEVEL);
if ( v == Vertex_handle() ) {
this->unregister_input_site( php.first, php.second );
}

View File

@ -119,7 +119,7 @@ public:
// ACCESS TO INFO
//---------------
inline const Info& info() const {
CGAL_precondition( info_has_been_set() );
CGAL_assume(info_has_been_set());
return info_;
}

View File

@ -204,7 +204,7 @@ namespace CGAL {
FT get_z(const Point_3& p){ return m_traits.compute_z_3_object()(p); }
FT get_coord(const Point_3& p, unsigned int d)
{
CGAL_assertion(d >= 0 && d < 3);
CGAL_assertion(d < 3);
switch (d)
{
case 0: return get_x(p);

View File

@ -171,7 +171,6 @@ namespace Point_set {
const std::size_t query_index,
std::vector<std::size_t>& neighbors) const {
CGAL_precondition(query_index >= 0);
CGAL_precondition(query_index < m_input_range.size());
Neighbor_search neighbor_search(

View File

@ -196,8 +196,6 @@ namespace Point_set {
const std::size_t,
const std::size_t query_index,
const std::vector<std::size_t>&) const {
CGAL_precondition(query_index >= 0);
CGAL_precondition(query_index < m_input_range.size());
const auto& key = *(m_input_range.begin() + query_index);
@ -246,8 +244,6 @@ namespace Point_set {
CGAL_precondition(region.size() > 0);
if (region.size() == 1) { // create new reference line and normal
CGAL_precondition(region[0] >= 0);
CGAL_precondition(region[0] < m_input_range.size());
// The best fit line will be a line through this point with
@ -272,8 +268,6 @@ namespace Point_set {
points.reserve(region.size());
for (std::size_t i = 0; i < region.size(); ++i) {
CGAL_precondition(region[i] >= 0);
CGAL_precondition(region[i] < m_input_range.size());
const auto& key = *(m_input_range.begin() + region[i]);

View File

@ -178,8 +178,6 @@ namespace Point_set {
points.clear();
for (std::size_t j = 0; j < neighbors.size(); ++j) {
CGAL_precondition(neighbors[j] >= 0);
CGAL_precondition(neighbors[j] < m_input_range.size());
const auto& key = *(m_input_range.begin() + neighbors[j]);

View File

@ -197,7 +197,6 @@ namespace Point_set {
const std::size_t query_index,
const std::vector<std::size_t>&) const {
CGAL_precondition(query_index >= 0);
CGAL_precondition(query_index < m_input_range.size());
const auto& key = *(m_input_range.begin() + query_index);
@ -246,8 +245,6 @@ namespace Point_set {
CGAL_precondition(region.size() > 0);
if (region.size() == 1) { // create new reference plane and normal
CGAL_precondition(region[0] >= 0);
CGAL_precondition(region[0] < m_input_range.size());
// The best fit plane will be a plane through this point with
@ -272,8 +269,6 @@ namespace Point_set {
points.reserve(region.size());
for (std::size_t i = 0; i < region.size(); ++i) {
CGAL_precondition(region[i] >= 0);
CGAL_precondition(region[i] < m_input_range.size());
const auto& key = *(m_input_range.begin() + region[i]);

View File

@ -178,8 +178,6 @@ namespace Point_set {
points.clear();
for (std::size_t j = 0; j < neighbors.size(); ++j) {
CGAL_precondition(neighbors[j] >= 0);
CGAL_precondition(neighbors[j] < m_input_range.size());
const auto& key = *(m_input_range.begin() + neighbors[j]);

View File

@ -169,8 +169,6 @@ namespace Point_set {
void operator()(
const std::size_t query_index,
std::vector<std::size_t>& neighbors) const {
CGAL_precondition(query_index >= 0);
CGAL_precondition(query_index < m_input_range.size());
const std::size_t sphere_center = query_index;

View File

@ -193,8 +193,6 @@ namespace Polygon_mesh {
points.clear();
for (std::size_t j = 0; j < neighbors.size(); ++j) {
CGAL_precondition(neighbors[j] >= 0);
CGAL_precondition(neighbors[j] < m_face_range.size());
const auto face = *(m_face_range.begin() + neighbors[j]);

View File

@ -51,8 +51,6 @@ namespace internal {
{ }
reference operator[](const key_type item_index) const {
CGAL_precondition(item_index >= 0);
CGAL_precondition(item_index < m_item_range.size());
const auto& key = *(m_item_range.begin() + item_index);

View File

@ -14,6 +14,20 @@
namespace CGAL {
namespace Total {
namespace internal {
//To avoid "fopen may be unsafe" on Visual.
bool open_file(FILE **fin, const char* filename)
{
#if defined(BOOST_MSVC)
return (fopen_s(fin, filename, "rw") == 0);
#else
*fin = fopen(filename, "rw");
return (fin != NULL);
#endif
}
} // namespace internal
void permuteLong(char *a)
{
@ -99,7 +113,7 @@ int lire_longueur_trace(const char * nomfich, long * long_trace)
FILE *fin;
int flag=0;
if ( (fin=fopen(nomfich,"rw"))!=NULL )
if ( internal::open_file(&fin, nomfich) )
{
fseek(fin,4,0);
if (fread(long_trace,4,1,fin) != 1) {
@ -118,7 +132,7 @@ int lire_nb_trace(const char * nomfich, long * nb_trace)
FILE *fin;
int flag=0;
if ( (fin=fopen(nomfich,"rw"))!=NULL )
if ( internal::open_file(&fin, nomfich) )
{
fseek(fin,8,0);
if (fread(nb_trace,4,1,fin) != 1) {
@ -137,7 +151,7 @@ int lire_nb_plan(const char * nomfich, long * nb_plan)
FILE *fin;
int flag=0;
if ( (fin=fopen(nomfich,"rw"))!=NULL )
if ( internal::open_file(&fin, nomfich) )
{
fseek(fin,12,0);
if (fread(nb_plan,4,1,fin) != 1) {
@ -157,7 +171,7 @@ int lire_nb_octet(const char * nomfich, long * nb_octet)
FILE *fin;
int flag=0;
if ( (fin=fopen(nomfich,"rw"))!=NULL )
if ( internal::open_file(&fin, nomfich) )
{
fseek(fin,36,0);
if (fread(nb_octet,4,1,fin) != 1) {
@ -177,7 +191,7 @@ int lire_longueur_entete(const char * nomfich, long * long_entete)
FILE *fin;
int flag=0;
if ( (fin=fopen(nomfich,"rw"))!=NULL )
if ( internal::open_file(&fin, nomfich) )
{
fseek(fin,72,0);
if (fread(long_entete,4,1,fin) != 1) {