xtypes
xtypes copied to clipboard
SIGABRT when directly accessing value of float from member
I am compiling using C++20 on GCC 11:
Simple Structure definition:
StructType msg("Msg");
msg.add_member("latitude", primitive_type<float>());
msg.add_member("longitude", primitive_type<float>());
This is inside a Catch2 test case:
// Works
REQUIRE(msg["latitude"].value<float>() == Approx(-11.11293));
// SIGABRT
REQUIRE(msg["latitude"] == Approx(-11.11293));
I believe this should error at compile time if it doesn't know what the return type is going to be.
It must be an issue specific to Catch2 because I'm not able to reproduce this on GoogleTest:
TEST (StructType, issue110)
{
StructType s("Msg");
s.add_member("latitude", primitive_type<float>());
s.add_member("longitude", primitive_type<float>());
DynamicData msg(s);
msg["latitude"] = -11.11293f;
EXPECT_FLOAT_EQ(msg["latitude"].value<float>(), -11.11293);
EXPECT_FLOAT_EQ(msg["latitude"], -11.11293);
}
works flawlessly on all supported platforms.
Bizarre. I'll try this again and then maybe report to catch2 instead.