From 03859abdeffa99bedad5757d28bcf52d3f1b08b0 Mon Sep 17 00:00:00 2001 From: yang-jihai Date: Sat, 16 Aug 2025 11:23:53 +0800 Subject: [PATCH] AnyCast throw bad_cast Signed-off-by: yang-jihai --- interface/inner_api/meta/any.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/inner_api/meta/any.h b/interface/inner_api/meta/any.h index d4f8cdbf..1d1ca90e 100644 --- a/interface/inner_api/meta/any.h +++ b/interface/inner_api/meta/any.h @@ -850,6 +850,9 @@ ValueType AnyCast(const Any& other) "any_cast(const any&) requires ValueType constructable from const " "remove_cv_t>&"); auto ptr = AnyCast(&other); + if (!ptr) { + throw std::bad_cast{}; + } return static_cast(*ptr); } -- Gitee