google / google/googletest

[Bug]: INSTANTIATE_TEST_SUITE_P fails to namespace func param

Open
#4,776 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

### Describe the issue

This example would fail when built with `g++ -Werror -Wshadow=compatible-local`:

```
class MyCodeTest : public ::testing::TestWithParam {};
TEST_P(MyCodeTest, Example) {}
INSTANTIATE_TEST_SUITE_P(
MyCode,
MyCodeTest,
::testing::Values(0),
[](const ::testing::TestParamInfo& info) {
return std::to_string(info.param);
});
```

### Steps to reproduce the problem

https://godbolt.org/z/65oz63933

### What version of GoogleTest are you using?

The repro uses gtest-1.10 but the issue remains in gtest-1.17 (latest release as of time of posting) and in `main` (as of time of posting).

### What operating system and version are you using?

Linux.

### What compiler and version are you using?

The repro uses gcc-15.1.

### What build system are you using?

N/A

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the INSTANTIATE_TEST_SUITE_P expansion involved in the Compiler Explorer reproduction at https://godbolt.org/z/65oz63933, using g++-15.1 with -Werror -Wshadow=compatible-local. Trace the generated names that cause the warning, then verify that the example builds cleanly with those flags once the issue is fixed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.