From a934911912e34b80cc6bc9208ceece19cb0daf83 Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Wed, 11 Feb 2026 09:22:42 +0000 Subject: [PATCH] Coding - Fix MSVC warnings C4723 and C4324 (#1060) --- .../TKMath/MathPoly/MathPoly_Quadratic.hxx | 17 +++++++++++++---- .../NCollection/NCollection_FlatDataMap.hxx | 7 +++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/FoundationClasses/TKMath/MathPoly/MathPoly_Quadratic.hxx b/src/FoundationClasses/TKMath/MathPoly/MathPoly_Quadratic.hxx index 97e2196f1d..df20778fa7 100644 --- a/src/FoundationClasses/TKMath/MathPoly/MathPoly_Quadratic.hxx +++ b/src/FoundationClasses/TKMath/MathPoly/MathPoly_Quadratic.hxx @@ -29,6 +29,10 @@ using namespace MathUtils; //! @param theA coefficient of x //! @param theB constant term //! @return result containing 0 or 1 root, or infinite solutions flag +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable : 4723) // potential divide by 0 - guarded by IsZero() check +#endif inline MathUtils::PolyResult Linear(double theA, double theB) { MathUtils::PolyResult aResult; @@ -43,14 +47,19 @@ inline MathUtils::PolyResult Linear(double theA, double theB) { aResult.Status = MathUtils::Status::NoSolution; } - return aResult; + } + else + { + aResult.Status = MathUtils::Status::OK; + aResult.NbRoots = 1; + aResult.Roots[0] = -theB / theA; } - aResult.Status = MathUtils::Status::OK; - aResult.NbRoots = 1; - aResult.Roots[0] = -theB / theA; return aResult; } +#ifdef _MSC_VER + #pragma warning(pop) +#endif //! Solve quadratic equation: a*x^2 + b*x + c = 0 //! Uses numerically stable formulas to avoid catastrophic cancellation. diff --git a/src/FoundationClasses/TKernel/NCollection/NCollection_FlatDataMap.hxx b/src/FoundationClasses/TKernel/NCollection/NCollection_FlatDataMap.hxx index 9e0297dd04..6352648aa8 100644 --- a/src/FoundationClasses/TKernel/NCollection/NCollection_FlatDataMap.hxx +++ b/src/FoundationClasses/TKernel/NCollection/NCollection_FlatDataMap.hxx @@ -85,6 +85,10 @@ private: //! Internal slot structure holding key, value, and metadata. //! Key and item storage is uninitialized until state becomes Used. +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable : 4324) // structure was padded due to alignment specifier +#endif struct Slot { alignas(TheKeyType) char myKeyStorage[sizeof(TheKeyType)]; @@ -114,6 +118,9 @@ private: return *reinterpret_cast(myItemStorage); } }; +#ifdef _MSC_VER + #pragma warning(pop) +#endif public: // **************** Iterator interface ****************