Skip to content

Implicit conversion warning with gcc 10 when using -Wconversion flag #3832

@Rebraws

Description

@Rebraws

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions