From 54246e12ad48bc1dbd416b0b415a4a48b337c2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Thu, 27 Jan 2022 10:04:40 +0100 Subject: [PATCH 1/2] Throw Exception when shape has invalid type Although the switch statement handles all (current) allowed values, from a C/C++ view point the enum may have any value of its underlying type. In this case the function has no return statement and runs into undefined behavior. Fixes build failures when built with "-Werror=return-type". --- libsrc/occ/python_occ_shapes.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 91e94c50..cbb35178 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -194,6 +194,7 @@ py::object CastShape(const TopoDS_Shape & s) case TopAbs_SHAPE: return py::cast(s); } + throw Exception("Invalid Shape type"); }; From e4a0733024b6aa2f1a893a15b7d99107cff4bd64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Mon, 1 Mar 2021 22:32:20 +0100 Subject: [PATCH 2/2] Throw in case "op" enum value is invalid --- libsrc/csg/solid.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libsrc/csg/solid.cpp b/libsrc/csg/solid.cpp index 52bd6321..a0ae3b0b 100644 --- a/libsrc/csg/solid.cpp +++ b/libsrc/csg/solid.cpp @@ -194,6 +194,7 @@ namespace netgen case ROOT: return s1->PointInSolid (p, eps); } + throw Exception("PointInSolid: invalid op"); } @@ -213,6 +214,7 @@ namespace netgen case ROOT: return s1->VecInSolid (p, v, eps); } + throw Exception("VecInSolid: invalid op"); } // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid @@ -233,6 +235,7 @@ namespace netgen case ROOT: return s1->VecInSolid2 (p, v1, v2, eps); } + throw Exception("VecInSolid2: invalid op"); }