Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unnecessary cast warnings when compiling tests with option -Wuseless-cast #4711

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

siddux
Copy link

@siddux siddux commented Jan 30, 2025

I've found some warnings when compiling my tests using the -Wuseless-cast flag. The proposed changes seems to fix it.

--- stderr: robot_health_checker                                                                                                                                              
In file included from /opt/ros/humble/src/gtest_vendor/./src/gtest.cc:122,
                 from /opt/ros/humble/src/gtest_vendor/src/gtest-all.cc:41:
/opt/ros/humble/src/gtest_vendor/./src/gtest-internal-inl.h: In member function ‘virtual void testing::internal::StreamingListener::SocketWriter::Send(const string&)’:
/opt/ros/humble/src/gtest_vendor/./src/gtest-internal-inl.h:1091:24: warning: useless cast to type ‘size_t’ {aka ‘long unsigned int’} [-Wuseless-cast]
 1091 |       const auto len = static_cast<size_t>(message.length());
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/ros/humble/src/gtest_vendor/src/gtest-all.cc:41:
/opt/ros/humble/src/gtest_vendor/./src/gtest.cc: In member function ‘std::string testing::internal::UnitTestImpl::CurrentOsStackTraceExceptTop(int)’:
/opt/ros/humble/src/gtest_vendor/./src/gtest.cc:821:7: warning: useless cast to type ‘int’ [-Wuseless-cast]
  821 |       static_cast<int>(GTEST_FLAG(stack_trace_depth)),
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/ros/humble/src/gtest_vendor/./src/gtest.cc: In static member function ‘static void testing::internal::XmlUnitTestResultPrinter::OutputXmlCDataSection(std::ostream*, const char*)’:
/opt/ros/humble/src/gtest_vendor/./src/gtest.cc:3754:20: warning: useless cast to type ‘std::streamsize’ {aka ‘long int’} [-Wuseless-cast]
 3754 |           segment, static_cast<std::streamsize>(next_segment - segment));
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---

Copy link

google-cla bot commented Jan 30, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants