← Back to team overview

kicad-developers team mailing list archive

[PATCH 07/12] Work around VC++ 2015 bug.

 

The combination of
 - template resolution
 - optimization
 - structured exception handling
 - chained operator=

appears to trigger a bug in the compiler.

As this code is nonsensical anyway (numeric_limits<>::min() returns the
smallest positive value for floating point types, but the largest negative
value for integral types), it should probably be rewritten.

This change just avoids the compiler bug, though.
---
 include/math/box2.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/math/box2.h b/include/math/box2.h
index 5bf6ddd..f941a8a 100644
--- a/include/math/box2.h
+++ b/include/math/box2.h
@@ -60,8 +60,12 @@ public:
 
     void SetMaximum()
     {
-        m_Pos.x  = m_Pos.y = coord_limits::min() / 2 + coord_limits::epsilon();
-        m_Size.x = m_Size.y = coord_limits::max() - coord_limits::epsilon();
+        coord_type min = coord_limits::min() / 2 + coord_limits::epsilon();
+        coord_type max = coord_limits::max() - coord_limits::epsilon();
+        m_Pos.x  = min;
+        m_Pos.y  = min;
+        m_Size.x = max;
+        m_Size.y = max;
     }
 
     Vec Centre() const

Follow ups

References