From 002a2cba6be693f152de6a45616531943f8d1ac8 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 16 Feb 2017 09:12:45 +0100 Subject: [PATCH] Fix (or work around?) strange bug on Windows The definition of std::max uses references for parameters, which leads to unnecessary storing of constants on the stack. If the stack is overwritten this leads to wrong results. max2() works around this using call-by-value. --- libsrc/meshing/curvedelems.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsrc/meshing/curvedelems.cpp b/libsrc/meshing/curvedelems.cpp index 48538359..4b2238a7 100644 --- a/libsrc/meshing/curvedelems.cpp +++ b/libsrc/meshing/curvedelems.cpp @@ -693,9 +693,9 @@ namespace netgen { facecoeffsindex[i] = nd; if (top.GetFaceType(i+1) == TRIG) - nd += max (0, (faceorder[i]-1)*(faceorder[i]-2)/2); + nd += max2 (0, (faceorder[i]-1)*(faceorder[i]-2)/2); else - nd += max (0, sqr(faceorder[i]-1)); + nd += max2 (0, sqr(faceorder[i]-1)); } facecoeffsindex[nfaces] = nd;