google / google/googletest

[Bug]: EXPECT_FATAL_FAILURE (et al) fail to compile when types have multiple template arguments

Open
#4,740 0 comments 1 reaction 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 is essentially the same as #3803, but for the specific case where the template arguments are being used with a _type_ rather than a function. The workaround of wrapping the expression in parentheses does not work when it's a _type_ with multiple parameters.

An alternative workaround is to use a typedef, but that's fairly ugly.

### Steps to reproduce the problem

```
EXPECT_FATAL_FAILURE(
{
std::pair foo = std::make_pair(4, 2);
ASSERT_EQ(foo.first, 2);
},
kErrorMsg);
```

### What version of GoogleTest are you using?

9756ee7cbaef1b6652065616ab832810a6032bbf

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

Linux

### What compiler and version are you using?

Whichever version is in use by the Fuchsia repo at this time - I'm not sure how to find that.

### What build system are you using?

GN

### Additional context

This is discussed in https://github.com/llvm/llvm-project/issues/53350, where they have a suggestion for how to resolve it.

Contributor guide

Open the contributing guide

Research direction

Start with the EXPECT_FATAL_FAILURE reproducer in the issue and compare the behavior with the related #3803 report. Review the suggested resolution in llvm/llvm-project#53350, then run the reproduction with a type using multiple template arguments. Done means the example compiles and the fatal-failure assertion behaves as expected without a typedef workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.