google / googletest

GoogleTest - Google Testing and Mocking Framework

Home Page:https://google.github.io/googletest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implicit conversion warning with gcc 10 when using -Wconversion flag

Rebraws opened this issue · comments

When building with gcc 10 and using the -Wconversion flag in my project, I have the following error:

_deps/googletest-src/googlemock/src/gmock-internal-utils.cc: In function ‘bool testing::internal::Base64Unescape(const string&, std::string*)’:
_deps/googletest-src/googlemock/src/gmock-internal-utils.cc:237:11: warning: conversion from ‘int’ to ‘char’ may change value [-Wconversion]
  237 |       dst |= src_bin << 2;

The implicit conversion happens here:

This can be fixed by adding a cast like:

dst |= static_cast<char>(src_bin << 2);

If it's okay, I'd be happy to submit a pull request to solve this issue.

Does the bug persist in the most recent commit?
Yes

What operating system and version are you using?
Ubuntu 20.04.3 LTS

What compiler and version are you using?
gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.04)

What build system are you using?
cmake version 3.16.3

Thanks, we'll fix this shortly.