Skip to main content
added 360 characters in body
Source Link
PiotrNycz
  • 25.1k
  • 10
  • 78
  • 123

I noticed a discrepancy between C++23 and C++26 code when using googlemock:

enum A { A1, A2 };
enum B { B1, B2 };
TEST(...)
{
   ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26
   ASSERT_THAT(A1, Eq(B1)); // does not compile in C++26
}

/opt/compiler-explorer/libs/googletest/trunk/googletest/include/gtest/gtest-matchers.h:700:16: error: no match for call to '(std::equal_to) (const A&, const B&)'

700 | return Op()(lhs, Unwrap(rhs_));

..compilers_c++_x86_gcc_15.2.0/include/c++/15.2.0/bits/stl_function.h:496:9: note: template argument deduction/substitution failed:

This simplified google mock code translates to use A1 == B1 and std::equal_to<void>{}(A1, B1):

enum A { A1, A2 };
enum B { B1, B2 };
void foo()
{
   // ASSERT_EQ(A1, B1); 
   if (A1 == B1) { ... }  // compiles fine in C++23 and C++26
   
   // ASSERT_THAT(A1, Eq(B1)); 
   if (std::equal_to<void>{}(A1, B1)) { ... } // does not compile in C++26
}

See godbolt.

This only happens in gcc(g++) -- clang compiles both versions.

It is, of course, a bug in test to compare values from different enums, and it is perfect that std::equal_to<void>{} catches that.

Is this behavior mandated by C++26, or just some kind of "bug" in gcc's std lib? It works that way only in gcc(g++). Clang compiles fine both ways in C++23 and C++26.

Will A1 == B1 produce compilation errors as well in the final version of C++26, or it is not going to change?

I noticed a discrepancy between C++23 and C++26 code when using googlemock:

enum A { A1, A2 };
enum B { B1, B2 };
TEST(...)
{
   ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26
   ASSERT_THAT(A1, Eq(B1)); // does not compile in C++26
}

This simplified google mock code translates to use A1 == B1 and std::equal_to<void>{}(A1, B1):

enum A { A1, A2 };
enum B { B1, B2 };
void foo()
{
   // ASSERT_EQ(A1, B1); 
   if (A1 == B1) { ... }  // compiles fine in C++23 and C++26
   
   // ASSERT_THAT(A1, Eq(B1)); 
   if (std::equal_to<void>{}(A1, B1)) { ... } // does not compile in C++26
}

See godbolt.

This only happens in gcc(g++) -- clang compiles both versions.

It is, of course, a bug in test to compare values from different enums, and it is perfect that std::equal_to<void>{} catches that.

Is this behavior mandated by C++26, or just some kind of "bug" in gcc's std lib? It works that way only in gcc(g++). Clang compiles fine both ways in C++23 and C++26.

Will A1 == B1 produce compilation errors as well in the final version of C++26, or it is not going to change?

I noticed a discrepancy between C++23 and C++26 code when using googlemock:

enum A { A1, A2 };
enum B { B1, B2 };
TEST(...)
{
   ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26
   ASSERT_THAT(A1, Eq(B1)); // does not compile in C++26
}

/opt/compiler-explorer/libs/googletest/trunk/googletest/include/gtest/gtest-matchers.h:700:16: error: no match for call to '(std::equal_to) (const A&, const B&)'

700 | return Op()(lhs, Unwrap(rhs_));

..compilers_c++_x86_gcc_15.2.0/include/c++/15.2.0/bits/stl_function.h:496:9: note: template argument deduction/substitution failed:

This simplified google mock code translates to use A1 == B1 and std::equal_to<void>{}(A1, B1):

enum A { A1, A2 };
enum B { B1, B2 };
void foo()
{
   // ASSERT_EQ(A1, B1); 
   if (A1 == B1) { ... }  // compiles fine in C++23 and C++26
   
   // ASSERT_THAT(A1, Eq(B1)); 
   if (std::equal_to<void>{}(A1, B1)) { ... } // does not compile in C++26
}

See godbolt.

This only happens in gcc(g++) -- clang compiles both versions.

It is, of course, a bug in test to compare values from different enums, and it is perfect that std::equal_to<void>{} catches that.

Is this behavior mandated by C++26, or just some kind of "bug" in gcc's std lib? It works that way only in gcc(g++). Clang compiles fine both ways in C++23 and C++26.

Will A1 == B1 produce compilation errors as well in the final version of C++26, or it is not going to change?

Became Hot Network Question
deleted 41 characters in body
Source Link
Remy Lebeau
  • 609.5k
  • 36
  • 516
  • 875

I noticed a discrepancy between C++23 and C++26 code when using [googlemock]googlemock:

enum A { A1, A2 };
enum B { B1, B2 };
TEST(...)
{
   ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26
   ASSERT_THAT(A1, Eq(B1)); // does not compile in C++26
}

enum A { A1, A2 };
enum B { B1, B2 };
TEST(...)
{
   ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26
   ASSERT_THAT(A1, Eq(B1)); // does not compile in C++26
}

This simplified google mock code simplified version translates to use A1 == B1 and std::equal_to<void>{}(A1, B1):

enum A { A1, A2 };
enum B { B1, B2 };
void foo()
{
   // ASSERT_EQ(A1, B1); 
   if (A1 == B1) { ... }  // compiles fine in C++23 and C++26
   
   // ASSERT_THAT(A1, Eq(B1)); 
   if (std::equal_to<void>{}(A1, B1)) { ... } // does not compile in C++26
}

enum A { A1, A2 };
enum B { B1, B2 };
void foo()
{
   // ASSERT_EQ(A1, B1); 
   if (A1 == B1) { ... }  // compiles fine in C++23 and C++26
   
   // ASSERT_THAT(A1, Eq(B1)); 
   if (std::equal_to<void>{}(A1, B1)) { ... } // does not compile in C++26
}

See godbolt.

This only happens in gcc(g++) -- clang compiles both versions.

It is, of course, a bug in test to compare values from different enums, and it is perfect that std::equal_to<void>{} catches that.

The question is - isIs this behavior mandated by C++26, or just some kind of "bug" in gccgcc's std lib? It works that way only in gcc(g++). Clang compiles fine both ways in C++23 and C++26.

The other question - willWill A1 == B1 producesproduce compilation errors as well in the final version of C++26, or it is not going to change?

I noticed discrepancy between C++23 and C++26 code when using [googlemock]:

enum A { A1, A2 };
enum B { B1, B2 };
TEST(...)
{
   ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26
   ASSERT_THAT(A1, Eq(B1)); // does not compile in C++26
}

This google mock code simplified version translates to use A1 == B1 and std::equal_to<void>{}(A1, B1):

enum A { A1, A2 };
enum B { B1, B2 };
void foo()
{
   // ASSERT_EQ(A1, B1); 
   if (A1 == B1) { ... }  // compiles fine in C++23 and C++26
   
   // ASSERT_THAT(A1, Eq(B1)); 
   if (std::equal_to<void>{}(A1, B1)) { ... } // does not compile in C++26
}

See godbolt.

This only happens in gcc(g++) -- clang compiles both versions.

It is of course a bug in test to compare values from different enums and it is perfect that std::equal_to<void>{} catches that.

The question is - is this behavior mandated by C++26, or just some kind of "bug" in gcc std lib? It works that way only in gcc(g++). Clang compiles fine both ways in C++23 and C++26.

The other question - will A1 == B1 produces compilation errors as well in final version of C++26, or it is not going to change?

I noticed a discrepancy between C++23 and C++26 code when using googlemock:

enum A { A1, A2 };
enum B { B1, B2 };
TEST(...)
{
   ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26
   ASSERT_THAT(A1, Eq(B1)); // does not compile in C++26
}

This simplified google mock code translates to use A1 == B1 and std::equal_to<void>{}(A1, B1):

enum A { A1, A2 };
enum B { B1, B2 };
void foo()
{
   // ASSERT_EQ(A1, B1); 
   if (A1 == B1) { ... }  // compiles fine in C++23 and C++26
   
   // ASSERT_THAT(A1, Eq(B1)); 
   if (std::equal_to<void>{}(A1, B1)) { ... } // does not compile in C++26
}

See godbolt.

This only happens in gcc(g++) -- clang compiles both versions.

It is, of course, a bug in test to compare values from different enums, and it is perfect that std::equal_to<void>{} catches that.

Is this behavior mandated by C++26, or just some kind of "bug" in gcc's std lib? It works that way only in gcc(g++). Clang compiles fine both ways in C++23 and C++26.

Will A1 == B1 produce compilation errors as well in the final version of C++26, or it is not going to change?

added 135 characters in body
Source Link
PiotrNycz
  • 25.1k
  • 10
  • 78
  • 123

I noticed discrepancy between C++23 and C++26 code when using [googlemock]:

enum A { A1, A2 };
enum B { B1, B2 };
TEST(...)
{
   ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26
   ASSERT_THAT(A1, Eq(B1)); // does not compile in C++26
}

This google mock code simplified version translates to use A1 == B1 and std::equal_to<void>{}(A1, B1):

enum A { A1, A2 };
enum B { B1, B2 };
void foo()
{
   // ASSERT_EQ(A1, B1); 
   if (A1 == B1) { ... }  // compiles fine in C++23 and C++26
   
   // ASSERT_THAT(A1, Eq(B1)); 
   if (std::equal_to<void>{}(A1, B1)) { ... } // does not compile in C++26
}

See godbolt.

This only happens in gcc(g++) -- clang compiles both versions.

It is of course a bug in test to compare values from different enums and it is perfect that std::equal_to<void>{} catches that.

The question is - is this behavior mandated by C++26, or just some kind of "bug" in gcc std lib? It works that way only in gcc(g++). Clang compiles fine both ways in C++23 and C++26.

The other question - will A1 == B1 produces compilation errors as well in final version of C++26, or it is not going to change?

I noticed discrepancy between C++23 and C++26 code when using [googlemock]:

enum A { A1, A2 };
enum B { B1, B2 };
TEST(...)
{
   ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26
   ASSERT_THAT(A1, Eq(B1)); // does not compile in C++26
}

This google mock code simplified version translates to use A1 == B1 and std::equal_to<void>{}(A1, B1):

enum A { A1, A2 };
enum B { B1, B2 };
void foo()
{
   // ASSERT_EQ(A1, B1); 
   if (A1 == B1) { ... }  // compiles fine in C++23 and C++26
   
   // ASSERT_THAT(A1, Eq(B1)); 
   if (std::equal_to<void>{}(A1, B1)) { ... } // does not compile in C++26
}

See godbolt.

This only happens in gcc(g++) -- clang compiles both versions.

It is of course a bug in test to compare values from different enums and it is perfect that std::equal_to<void>{} catches that.

The question is - is this behavior mandated by C++26, or just some kind of "bug" in gcc std lib? It works that way only in gcc(g++). Clang compiles fine both ways in C++23 and C++26.

I noticed discrepancy between C++23 and C++26 code when using [googlemock]:

enum A { A1, A2 };
enum B { B1, B2 };
TEST(...)
{
   ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26
   ASSERT_THAT(A1, Eq(B1)); // does not compile in C++26
}

This google mock code simplified version translates to use A1 == B1 and std::equal_to<void>{}(A1, B1):

enum A { A1, A2 };
enum B { B1, B2 };
void foo()
{
   // ASSERT_EQ(A1, B1); 
   if (A1 == B1) { ... }  // compiles fine in C++23 and C++26
   
   // ASSERT_THAT(A1, Eq(B1)); 
   if (std::equal_to<void>{}(A1, B1)) { ... } // does not compile in C++26
}

See godbolt.

This only happens in gcc(g++) -- clang compiles both versions.

It is of course a bug in test to compare values from different enums and it is perfect that std::equal_to<void>{} catches that.

The question is - is this behavior mandated by C++26, or just some kind of "bug" in gcc std lib? It works that way only in gcc(g++). Clang compiles fine both ways in C++23 and C++26.

The other question - will A1 == B1 produces compilation errors as well in final version of C++26, or it is not going to change?

Source Link
PiotrNycz
  • 25.1k
  • 10
  • 78
  • 123
Loading