google / google/googletest

[Bug]: GTEST_FATAL_FAILURE_ and GTEST_SKIP_ return void expression

Open Beginner friendly
#4,625 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
39.6k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

Describe the issue

The internal macros GTEST_FATAL_FAILURE_ and GTEST_SKIP_ return the void expression GTEST_MESSAGE_.

I would expect them to call GTEST_MESSAGE_ and then return.

Steps to reproduce the problem

Run clazy static code analyzer on simple TestCase that uses one of the ASSERT_ macros.

It will e.g. report

main.cpp:39:5: warning: Returning a void expression [-Wclazy-returning-void-expression]
    ASSERT_TRUE(true);
    ^
/usr/src/googletest/googletest/include/gtest/gtest.h:1990:32: note: expanded from macro 'ASSERT_TRUE'
#define ASSERT_TRUE(condition) GTEST_ASSERT_TRUE(condition)
                               ^
/usr/src/googletest/googletest/include/gtest/gtest.h:1973:23: note: expanded from macro 'GTEST_ASSERT_TRUE'
                      GTEST_FATAL_FAILURE_)
What version of GoogleTest are you using?

1.11.0

What operating system and version are you using?

Ubuntu 22.04.5

What compiler and version are you using?

clang 14.0 with clazy 1.11 plugin

What build system are you using?

cmake 3.24.4

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in googletest/include/gtest/gtest.h, where the diagnostic expands through ASSERT_TRUE, GTEST_FATAL_FAILURE_, GTEST_SKIP_, and GTEST_MESSAGE_. Reproduce the warning with clang 14 and clazy on a simple TestCase, then verify that the macros no longer return a void expression while the existing assertion behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.