diff --git a/DDCore/src/Primitives.cpp b/DDCore/src/Primitives.cpp
index a9f34639c7bedac2a4817d11e142ac76627c429e..eea237cfd8a90df605b0369194a892e98cd15dd5 100644
--- a/DDCore/src/Primitives.cpp
+++ b/DDCore/src/Primitives.cpp
@@ -461,10 +461,10 @@ void* dd4hep::Cast::apply_dynCast(const Cast& to, const void* ptr) const
       r = cast_wrap(ptr, (const class_t*) abi_class, src_type, -1);
       if (r)      return r;
     }
-#endif
 #endif
     throw unrelated_type_error(type, to.type, "Failed to apply abi dynamic cast operation!");
   }
+#endif
   throw unrelated_type_error(type, to.type, "Target type is not an abi class type!");
 }