Commit c04f703a by Eric Fiselier

Fix signed integer overflow UB in complexity computations.

Previously the FittingCurve functions for n^2 and n^3 did the calculation using int types. This can overflow and cause UB. This patch changes the calculations to use std::pow to prevent this. Also re-enable VC 2013 appveyor bot since I *hope* this is what was causing the failures.
parent 5121b854
......@@ -12,7 +12,7 @@ platform:
environment:
matrix:
# - compiler: msvc-12-seh
- compiler: msvc-12-seh
- compiler: msvc-14-seh
- compiler: gcc-4.9.2-posix
# - compiler: gcc-4.8.4-posix
......
......@@ -31,9 +31,9 @@ BigOFunc* FittingCurve(BigO complexity) {
case oN:
return [](int n) -> double { return n; };
case oNSquared:
return [](int n) -> double { return n * n; };
return [](int n) -> double { return std::pow(n, 2); };
case oNCubed:
return [](int n) -> double { return n * n * n; };
return [](int n) -> double { return std::pow(n, 3); };
case oLogN:
return [](int n) { return std::log2(n); };
case oNLogN:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment