Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CGAL: Deal with CGAL_assertion(false) #8496

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions AABB_tree/demo/AABB_tree/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1252,9 +1252,7 @@ void Scene::cutting_plane(bool override)
return;
}

// Should not be here
std::cerr << "Unknown cut_plane type" << std::endl;
CGAL_assertion(false);
CGAL_unreachable();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1665,13 +1665,8 @@ class Algebraic_curve_kernel_2 : public AlgebraicKernel_d_1{
const Polynomial_2& f = ca1.polynomial_2();
const Polynomial_2& g = ca2.polynomial_2();

if(f == g) {
// both curves are equal, but have different representations!
// std::cout <<"f: " << f <<std::endl;
// std::cout <<"g: " << g <<std::endl;
CGAL_assertion(false);
return false;
}
CGAL_assertion_msg(f != g, "both curves are equal, but have different representations!");

Gcd_cache_2& gcd_cache = _m_kernel->gcd_cache_2();
typedef typename Curve_analysis_2::size_type size_type;
Polynomial_2 gcd = gcd_cache(std::make_pair(f,g));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ class Curve_analysis_2 : public ::CGAL::Handle_with_policy< Rep_ > {
break;
}
default:{
CGAL_assertion(false); // !!! Never reached
CGAL_unreachable();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class Lazy_alpha_nt_2
exact_ = Exact_squared_radius()( to_exact(*data().p0),to_exact(*data().p1),to_exact(*data().p2) );
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}
}

Expand All @@ -229,7 +229,7 @@ class Lazy_alpha_nt_2
approx_ = Approx_squared_radius()( to_approx(*data().p0),to_approx(*data().p1),to_approx(*data().p2) );
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Lazy_alpha_nt_3{
exact_ = Exact_squared_radius()( to_exact(*data().p0),to_exact(*data().p1),to_exact(*data().p2),to_exact(*data().p3) );
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}
}

Expand All @@ -224,7 +224,7 @@ class Lazy_alpha_nt_3{
approx_ = Approx_squared_radius()( to_approx(*data().p0),to_approx(*data().p1),to_approx(*data().p2),to_approx(*data().p3) );
break;
default:
CGAL_assertion(false);
CGAL_unreachable();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,9 @@ class Td_X_trapezoid : public Handle
case CGAL_TD_VERTEX:
return TD_VERTEX;
default:
CGAL_assertion(false);
return TD_TRAPEZOID;
}
CGAL_unreachable();
}
}

/*! Access trapezoid type flag. */
CGAL_TD_INLINE unsigned char type_flag() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ bool is_index_map_valid(const CGAL::internal_np::face_index_t, FaceIndexProperty
return is_index_map_valid(face_index_map, num_faces(g), faces(g));
}

template <typename PropertyTag, typename IndexPropertyMap, typename Graph>
void initialize_index_map(const PropertyTag, IndexPropertyMap, const Graph&)
{
// Unknown parameter; should never be here.
CGAL_assertion(false);
}

template <typename IndexPropertyMap,
typename Graph,
bool is_writable = CGAL::internal::Is_writable_property_map<IndexPropertyMap>::value>
Expand Down Expand Up @@ -120,12 +113,6 @@ struct Index_map_initializer
put(face_index_map, fd, i++);
}

template <typename PropertyTag>
void operator()(const PropertyTag, IndexPropertyMap, const Graph&)
{
// Unknown parameter; should never be here.
CGAL_assertion(false);
}
};

template <typename IndexPropertyMap, typename Graph>
Expand Down
2 changes: 1 addition & 1 deletion Classification/include/CGAL/Classification/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Image
// https://github.com/boostorg/core/issues/148
Image(const Image&)
{
CGAL_assertion(false);
CGAL_unreachable();
}

Image () : m_width(0), m_height(0), m_depth(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,8 @@ namespace CGAL {
{
// Allocate a dart for null_dart_descriptor
assert(mdarts.empty()); // the compact container is empty
Dart_index local_null_dart_descriptor = mdarts.emplace();
if(local_null_dart_descriptor!=0)
{
std::cerr<<"[ERROR] fatal in Combinatorial_map_storage_with_index::init_storage"
<<std::endl;
CGAL_assertion(false);
}
CGAL_assertion_code( Dart_index local_null_dart_descriptor = ) mdarts.emplace();
CGAL_assertion_msg(local_null_dart_descriptor ==0, "[ERROR] fatal in Combinatorial_map_storage_with_index::init_storage");
}

void clear_storage()
Expand Down
6 changes: 2 additions & 4 deletions Cone_spanners_2/include/CGAL/Compute_cone_boundaries_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ class Compute_cone_boundaries_2 {
DirectionOutputIterator operator()(const unsigned int cone_number,
const Direction_2& initial_direction,
DirectionOutputIterator result) {
if (cone_number<2) {
std::cout << "The number of cones must be larger than 1!" << std::endl;
CGAL_assertion(false);
}

CGAL_assertion_msg(cone_number>1, "The number of cones must be larger than 1");

*result++ = initial_direction;

Expand Down
5 changes: 1 addition & 4 deletions Cone_spanners_2/include/CGAL/Construct_theta_graph_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ class Construct_theta_graph_2 {
): cone_number(k), cones_choice(cones_selected), rays(std::vector<Direction_2>(k))

{
if (k<2) {
std::cout << "The number of cones must be larger than 1!" << std::endl;
CGAL_assertion(false);
}
CGAL_assertion_msg(k>1, "The number of cones must be larger than 1");

/* Initialize a functor, specialization will happen here depending on the kernel type to
compute the cone boundaries either exactly or inexactly */
Expand Down
5 changes: 1 addition & 4 deletions Cone_spanners_2/include/CGAL/Construct_yao_graph_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ class Construct_yao_graph_2 {
): cone_number(k), cones_choice(cones_selected), rays(std::vector<Direction_2>(k))

{
if (k<2) {
std::cout << "The number of cones must be larger than 1!" << std::endl;
CGAL_assertion(false);
}
CGAL_assertion_msg(k>1, "The number of cones must be larger than 1");

/* Initialize a functor, specialization will happen here depending on the kernel type to
compute the cone boundaries either exactly or inexactly */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,6 @@ Aff_transformation_repH2<R>::homogeneous(int i, int j) const
}
}
CGAL_unreachable();
return RT(0);
}

template < class R >
Expand Down Expand Up @@ -920,7 +919,6 @@ Translation_repH2<R>::homogeneous(int i, int j) const
}
}
CGAL_unreachable();
return RT(0);
}

template < class R >
Expand Down Expand Up @@ -955,7 +953,6 @@ Translation_repH2<R>::cartesian(int i, int j) const
}
}
CGAL_unreachable();
return FT(0);
}

template < class R >
Expand Down Expand Up @@ -991,7 +988,6 @@ homogeneous(int i, int j) const
}
}
CGAL_unreachable();
return RT(0);
}

template < class R >
Expand Down Expand Up @@ -1027,7 +1023,6 @@ cartesian(int i, int j) const
}
}
CGAL_unreachable();
return FT(0);
}

template < class R >
Expand Down Expand Up @@ -1063,7 +1058,6 @@ homogeneous(int i, int j) const
}
}
CGAL_unreachable();
return RT(0);
}

template <class R>
Expand Down Expand Up @@ -1099,7 +1093,6 @@ cartesian(int i, int j) const
}
}
CGAL_unreachable();
return FT(0);
}

template < class R >
Expand Down Expand Up @@ -1136,7 +1129,6 @@ homogeneous(int i, int j) const
}
}
CGAL_unreachable();
return RT(0);
}

template <class R>
Expand Down Expand Up @@ -1173,7 +1165,6 @@ cartesian(int i, int j) const
}
}
CGAL_unreachable();
return FT(0);
}

} //namespace CGAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ homogeneous(int i, int j) const
}
}
CGAL_unreachable();
return RT0;
}

template < class R >
Expand Down Expand Up @@ -895,7 +894,6 @@ Translation_repH3<R>::homogeneous(int i, int j) const
}
}
CGAL_unreachable();
return RT0;
}

template < class R >
Expand Down
4 changes: 2 additions & 2 deletions Intersections_2/include/CGAL/Intersections_2/Ray_2_Ray_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <CGAL/Segment_2.h>
#include <CGAL/Point_2.h>
#include <CGAL/kernel_assertions.h>
#include <CGAL/assertions.h>
#include <CGAL/number_utils.h>
#include <CGAL/Intersections_2/Line_2_Line_2.h>
#include <CGAL/Intersection_traits_2.h>
Expand Down Expand Up @@ -185,8 +186,7 @@ Ray_2_Ray_2_pair<K>::intersection_type() const
}
}
default:
CGAL_kernel_assertion(false); // should not be reached:
return _result;
CGAL_unreachable();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <CGAL/Point_2.h>
#include <CGAL/Line_2.h>
#include <CGAL/kernel_assertions.h>
#include <CGAL/assertions.h>
#include <CGAL/number_utils.h>
#include <CGAL/Intersections_2/Line_2_Line_2.h>
#include <CGAL/Intersection_traits_2.h>
Expand Down Expand Up @@ -203,8 +204,7 @@ Ray_2_Segment_2_pair<K>::intersection_type() const
}
}
default:
CGAL_kernel_assertion(false); // should not be reached:
return _result;
CGAL_unreachable();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <CGAL/Segment_2.h>
#include <CGAL/Point_2.h>
#include <CGAL/kernel_assertions.h>
#include <CGAL/assertions.h>
#include <CGAL/number_utils.h>
#include <CGAL/predicates_on_points_2.h>
#include <CGAL/Line_2.h>
Expand Down Expand Up @@ -141,8 +142,7 @@ seg_seg_do_intersect_crossing(
default:
CGAL_unreachable();
}
CGAL_kernel_assertion(false);
return S2S2_inter_info(false);
CGAL_unreachable();
}

// used internally by Arr_segment_traits_2template <class K>
Expand Down Expand Up @@ -202,8 +202,7 @@ seg_seg_do_intersect_contained(
default:
CGAL_unreachable();
}
CGAL_kernel_assertion(false);
return S2S2_inter_info(false);
CGAL_unreachable();
}

// used internally by Arr_segment_traits_2
Expand Down Expand Up @@ -319,8 +318,7 @@ do_intersect_with_info(const typename K::Segment_2 &seg1,
CGAL_unreachable();
}

CGAL_kernel_assertion(false);
return S2S2_inter_info(false);
CGAL_unreachable();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <CGAL/enum.h>
#include <CGAL/kernel_assertions.h>
#include <CGAL/assertions.h>

namespace CGAL {
namespace Intersections {
Expand Down Expand Up @@ -57,13 +58,11 @@ do_intersect(const typename K::Triangle_3& t,
case POSITIVE: return (orientation(p,q,c,a) != NEGATIVE);
case NEGATIVE: return (orientation(p,q,c,a) != POSITIVE);
case COPLANAR: return true;
default: // should not happen.
CGAL_kernel_assertion(false);
return false;
default:
CGAL_unreachable();
}
default: // should not happen.
CGAL_kernel_assertion(false);
return false;
default:
CGAL_unreachable();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <CGAL/enum.h>
#include <CGAL/kernel_assertions.h>
#include <CGAL/assertions.h>

namespace CGAL {
namespace Intersections {
Expand Down Expand Up @@ -43,8 +44,7 @@ do_intersect(const typename K::Triangle_3& t,
case ON_ORIENTED_BOUNDARY:
return true;
default:// should not happen.
CGAL_kernel_assertion(false);
return false;
CGAL_unreachable();
}
}

Expand Down
Loading