Description
In some cases UTBot tries to construct anonymous union from bytes returned by KLEE. But from_bytes function needs constructed type as a template parameter, so generated tests cannot be compiled.
Example
struct StructWithAnonymousUnion {
union {
int x;
struct {
char c;
double d;
};
long long *ptr;
};
};
struct StructWithAnonymousUnion struct_with_anonymous_union_as_return_type(int a, int b) {
struct StructWithAnonymousUnion ans;
if (a > b) {
ans.ptr = 0;
} else if (a < b) {
ans.x = 153;
} else {
ans.c = 'k';
ans.d = 1.0101;
}
return ans;
}
To Reproduce
Steps to reproduce the behavior:
Copy the example above to your project
Generate tests for function struct_with_anonymous_union_as_return_type
Try to run generated tests
Expected behavior
Tests are supposed to be executed.
Actual behavior
Compilation error.
Generated test
TEST(regression, struct_with_anonymous_union_as_return_type_test1)
{
// Construct input
int a = 0;
int b = 0;
// Expected output
struct StructWithAnonymousUnion expected = {
from_bytes<StructWithAnonymousUnion::>({107, -85, -85, -85, -85, -85, -85, -85, -102, 8, 27, -98, 94, 41, -16, 63})
};
// Trigger the function
struct StructWithAnonymousUnion actual = struct_with_anonymous_union_as_return_type(a, b);
// Check results
EXPECT_EQ(expected.x, actual.x);
EXPECT_EQ(expected.c, actual.c);
EXPECT_DOUBLE_EQ(expected.d, actual.d);
}
Description In some cases UTBot tries to construct anonymous union from bytes returned by KLEE. But
from_bytes
function needs constructed type as a template parameter, so generated tests cannot be compiled.Example
To Reproduce Steps to reproduce the behavior:
struct_with_anonymous_union_as_return_type
Expected behavior Tests are supposed to be executed.
Actual behavior Compilation error.
Generated test
Logs