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 @@
#include <vtkm/worklet/StableSortIndices.h>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <random>
#include <string>
......@@ -1196,7 +1197,9 @@ int main(int argc, char* argv[])
for (int i = 1; i < argc; ++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")
{
config.BenchmarkFlags |= vtkm::benchmarking::COPY;
......@@ -1253,7 +1256,9 @@ int main(int argc, char* 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")
{
config.ExtendedTypeList = false;
......@@ -1272,7 +1277,9 @@ int main(int argc, char* 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")
{
config.TestArraySizeBytes = false;
......@@ -1288,7 +1295,9 @@ int main(int argc, char* 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")
{
config.TestArraySizeValues = false;
......
......@@ -35,6 +35,7 @@
#include <vtkm/benchmarking/Benchmarker.h>
#include <vtkm/cont/testing/Testing.h>
#include <cctype>
#include <random>
#include <string>
......@@ -922,7 +923,9 @@ int main(int argc, char* argv[])
for (int i = 1; i < argc; ++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")
{
benchmarks |= vtkm::benchmarking::BLACK_SCHOLES;
......
......@@ -32,6 +32,7 @@
#include <vtkm/benchmarking/Benchmarker.h>
#include <vtkm/cont/testing/Testing.h>
#include <cctype>
#include <random>
#include <string>
......@@ -470,7 +471,9 @@ int main(int argc, char* argv[])
for (int i = 1; i < argc; ++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")
{
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