A bitfield that is declared with an enum type does not compile in a REQUIRE statement.
error: cannot bind bit-field ‘bf.CATCH2_INTERNAL_TEST_0()::BF::e’ to ‘CATCH2_INTERNAL_TEST_0()::E&’ 17 | REQUIRE(bf.e == ONE);
Repro:
#include <catch2/catch_all.hpp>
TEST_CASE("Bitfield of enum", "[critical]")
{
enum E
{
ZERO,
ONE,
};
struct BF
{
E e : 1;
};
BF bf{};
REQUIRE(bf.e == ONE);
}
gcc 11.4.1
gcc 12.2.0
Tested at catch2 commit: 715558f
Note workaround is to static_cast the bitfield to the enum type.