From b58b6bc36ed35996ceabd598858cd38a61348457 Mon Sep 17 00:00:00 2001 From: gammasoft71 Date: Fri, 20 Sep 2024 22:29:50 +0200 Subject: [PATCH] Fix warning --- .../include/xtd/internal/__iformatable_formatter.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/xtd.core/include/xtd/internal/__iformatable_formatter.h b/src/xtd.core/include/xtd/internal/__iformatable_formatter.h index 78ae4ad4363a..77dc02b42b4f 100644 --- a/src/xtd.core/include/xtd/internal/__iformatable_formatter.h +++ b/src/xtd.core/include/xtd/internal/__iformatable_formatter.h @@ -21,10 +21,11 @@ std::string __to_string_istringable_to_string(const xtd::istringable* obj); template static std::string __to_string_polymorphic(const value_t& value, const std::string& fmt, const std::locale& loc, std::true_type) { - if (dynamic_cast(&value)) return std::string {"exception: "} + dynamic_cast(value).what(); - if (dynamic_cast(&value)) return dynamic_cast(value).__opague_internal_formatable__(reinterpret_cast(&fmt), reinterpret_cast(&loc), 0, INTPTR_MAX); - if (dynamic_cast(&value)) return __to_string_istringable_to_string(dynamic_cast(&value)); - if (dynamic_cast(&value)) return __to_string_object_to_string(dynamic_cast(&value)); + auto value_ptr = &value; + if (dynamic_cast(value_ptr)) return std::string {"exception: "} + dynamic_cast(value).what(); + if (dynamic_cast(value_ptr)) return dynamic_cast(value).__opague_internal_formatable__(reinterpret_cast(&fmt), reinterpret_cast(&loc), 0, INTPTR_MAX); + if (dynamic_cast(value_ptr)) return __to_string_istringable_to_string(dynamic_cast(&value)); + if (dynamic_cast(value_ptr)) return __to_string_object_to_string(dynamic_cast(value_ptr)); __format_exception(typeid(value)); return {}; }