Commit 545db0c7 authored by Robert Maynard's avatar Robert Maynard
Browse files

Correct std::tolower warnings under MSVC2017.

Using std::tolower with std::string actually can cause undefined behavior,
and only MSVC 2017 looks to complain about it. You can find more
information on the exact reason at: http://en.cppreference.com/w/cpp/string/byte/tolower
parent c3c8caa7
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <vtkm/worklet/StableSortIndices.h> #include <vtkm/worklet/StableSortIndices.h>
#include <algorithm> #include <algorithm>
#include <cctype>
#include <cmath> #include <cmath>
#include <random> #include <random>
#include <string> #include <string>
...@@ -1196,7 +1197,9 @@ int main(int argc, char* argv[]) ...@@ -1196,7 +1197,9 @@ int main(int argc, char* argv[])
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)
{ {
std::string arg = argv[i]; std::string arg = argv[i];
std::transform(arg.begin(), arg.end(), arg.begin(), ::tolower); std::transform(arg.begin(), arg.end(), arg.begin(), [](char c) {
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
});
if (arg == "copy") if (arg == "copy")
{ {
config.BenchmarkFlags |= vtkm::benchmarking::COPY; config.BenchmarkFlags |= vtkm::benchmarking::COPY;
...@@ -1253,7 +1256,9 @@ int main(int argc, char* argv[]) ...@@ -1253,7 +1256,9 @@ int main(int argc, char* argv[])
{ {
++i; ++i;
arg = argv[i]; arg = argv[i];
std::transform(arg.begin(), arg.end(), arg.begin(), ::tolower); std::transform(arg.begin(), arg.end(), arg.begin(), [](char c) {
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
});
if (arg == "base") if (arg == "base")
{ {
config.ExtendedTypeList = false; config.ExtendedTypeList = false;
...@@ -1272,7 +1277,9 @@ int main(int argc, char* argv[]) ...@@ -1272,7 +1277,9 @@ int main(int argc, char* argv[])
{ {
++i; ++i;
arg = argv[i]; arg = argv[i];
std::transform(arg.begin(), arg.end(), arg.begin(), ::tolower); std::transform(arg.begin(), arg.end(), arg.begin(), [](char c) {
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
});
if (arg == "off") if (arg == "off")
{ {
config.TestArraySizeBytes = false; config.TestArraySizeBytes = false;
...@@ -1288,7 +1295,9 @@ int main(int argc, char* argv[]) ...@@ -1288,7 +1295,9 @@ int main(int argc, char* argv[])
{ {
++i; ++i;
arg = argv[i]; arg = argv[i];
std::transform(arg.begin(), arg.end(), arg.begin(), ::tolower); std::transform(arg.begin(), arg.end(), arg.begin(), [](char c) {
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
});
if (arg == "off") if (arg == "off")
{ {
config.TestArraySizeValues = false; config.TestArraySizeValues = false;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <vtkm/benchmarking/Benchmarker.h> #include <vtkm/benchmarking/Benchmarker.h>
#include <vtkm/cont/testing/Testing.h> #include <vtkm/cont/testing/Testing.h>
#include <cctype>
#include <random> #include <random>
#include <string> #include <string>
...@@ -922,7 +923,9 @@ int main(int argc, char* argv[]) ...@@ -922,7 +923,9 @@ int main(int argc, char* argv[])
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)
{ {
std::string arg = argv[i]; std::string arg = argv[i];
std::transform(arg.begin(), arg.end(), arg.begin(), ::tolower); std::transform(arg.begin(), arg.end(), arg.begin(), [](char c) {
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
});
if (arg == "blackscholes") if (arg == "blackscholes")
{ {
benchmarks |= vtkm::benchmarking::BLACK_SCHOLES; benchmarks |= vtkm::benchmarking::BLACK_SCHOLES;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <vtkm/benchmarking/Benchmarker.h> #include <vtkm/benchmarking/Benchmarker.h>
#include <vtkm/cont/testing/Testing.h> #include <vtkm/cont/testing/Testing.h>
#include <cctype>
#include <random> #include <random>
#include <string> #include <string>
...@@ -470,7 +471,9 @@ int main(int argc, char* argv[]) ...@@ -470,7 +471,9 @@ int main(int argc, char* argv[])
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)
{ {
std::string arg = argv[i]; std::string arg = argv[i];
std::transform(arg.begin(), arg.end(), arg.begin(), ::tolower); std::transform(arg.begin(), arg.end(), arg.begin(), [](char c) {
return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
});
if (arg == "celltopoint") if (arg == "celltopoint")
{ {
benchmarks |= vtkm::benchmarking::CELL_TO_POINT; benchmarks |= vtkm::benchmarking::CELL_TO_POINT;
......
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