googletest icon indicating copy to clipboard operation
googletest copied to clipboard

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

Open hjfreyer opened this issue 7 months ago • 0 comments

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<int, int> 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.

hjfreyer avatar Mar 28 '25 19:03 hjfreyer