From 9f97e4ae6134a833654de6f6782e9116c3a2d13a Mon Sep 17 00:00:00 2001 From: Ferry Huberts Date: Wed, 16 Aug 2023 20:30:22 +0200 Subject: [PATCH] Fix compiler warnings (-Wdangling-reference) Signed-off-by: Ferry Huberts --- cmake/compiler-flags.cmake | 2 -- src/oatpp/core/data/mapping/type/Enum.hpp | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/cmake/compiler-flags.cmake b/cmake/compiler-flags.cmake index d8520214..814e1729 100644 --- a/cmake/compiler-flags.cmake +++ b/cmake/compiler-flags.cmake @@ -274,8 +274,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU) add_compiler_flags(4.8 "-Wno-suggest-attribute=format") add_compiler_flags(9.1 "-Wno-pessimizing-move") - - add_compiler_flags(13.0 "-Wno-dangling-reference") endif (CMAKE_CXX_COMPILER_ID MATCHES GNU) diff --git a/src/oatpp/core/data/mapping/type/Enum.hpp b/src/oatpp/core/data/mapping/type/Enum.hpp index 5559cd0f..5d3efa72 100644 --- a/src/oatpp/core/data/mapping/type/Enum.hpp +++ b/src/oatpp/core/data/mapping/type/Enum.hpp @@ -495,8 +495,7 @@ Void EnumInterpreterAsString::fromInterpretation(const Void& interVa } try { - const auto &entry = EnumOW::getEntryByName(interValue.template cast()); - return EnumOW(entry.value); + return EnumOW(EnumOW::getEntryByName(interValue.template cast()).value); } catch (const std::runtime_error&) { // TODO - add a specific error for this. error = EnumInterpreterError::ENTRY_NOT_FOUND; }