From 691fe549d71cf808b00e0d65e5fe2d3abc0b9490 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 18 Jun 2024 13:52:42 +0200 Subject: [PATCH] taxonony::cast throws exceptions now on invalid casts --- src/ifcgeom/taxonomy.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ifcgeom/taxonomy.h b/src/ifcgeom/taxonomy.h index d795cbb91a..c74080cfaa 100644 --- a/src/ifcgeom/taxonomy.h +++ b/src/ifcgeom/taxonomy.h @@ -1239,7 +1239,11 @@ typedef item const* ptr; if (pwupg) { return pwupg; } - return std::static_pointer_cast(u); + if (auto r = std::dynamic_pointer_cast(u)) { + return r; + } else { + throw std::runtime_error("Unexpected topology"); + } } template std::shared_ptr dcast(const std::shared_ptr& u) {