mirror of
https://github.com/google/benchmark.git
synced 2025-03-10 01:00:08 +08:00
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.
This commit is contained in:
parent
5121b8546b
commit
c04f703ab4
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user