Add test with misaligned allocation

This commit is contained in:
Smertig 2021-05-09 13:07:01 +03:00 committed by The Phantom Derpstorm
parent 3372d4fe9b
commit 35c71f1b47
3 changed files with 69 additions and 34 deletions

View File

@ -78,6 +78,8 @@ function(sol2_create_basic_test test_target_name target_sol)
PRIVATE ${target_sol})
target_compile_definitions(${test_target_name}
PRIVATE SOL_ALL_SAFETIES_ON=1)
target_compile_definitions(${test_target_name}
PRIVATE SOL_TESTS_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P})
endfunction()
add_subdirectory(inclusion)

View File

@ -0,0 +1,32 @@
#include <sol/sol.hpp>
#if SOL_TESTS_SIZEOF_VOID_P == 4
inline namespace sol2_regression_test_XXXX {
struct Test {
std::uint64_t dummy;
};
} // namespace sol2_regression_test_XXXX
unsigned int regression_XXXX() {
sol::state lua;
static_assert(sizeof(Test) == 8);
static_assert(alignof(Test) == 8);
static_assert(sizeof(Test*) == 4);
static_assert(alignof(Test*) == 4);
/// [sol2] An error occurred and panic has been invoked: aligned allocation of userdata block (data section) for 'sol2_regression_test_XXXX::Test' failed
/// Note: may not panic depending on alignment of local variable `alignment_shim` in sol::detail::aligned_space_for
lua["test"] = Test {};
return 0;
}
#else
unsigned int regression_XXXX() {
return 0;
}
#endif

View File

@ -10,9 +10,10 @@ extern unsigned int regression_1087();
extern unsigned int regression_1095();
extern unsigned int regression_1096();
extern unsigned int regression_1149();
extern unsigned int regression_XXXX();
static f_ptr* const regression_tests_regressions[]
= { &regression_1008, &regression_1000, &regression_1067, &regression_1072, &regression_1087, &regression_1095, &regression_1096, &regression_1149 };
= { &regression_1008, &regression_1000, &regression_1067, &regression_1072, &regression_1087, &regression_1095, &regression_1096, &regression_1149, &regression_XXXX };
static const int regression_tests_sizeof_regressions = sizeof(regression_tests_regressions) / sizeof(regression_tests_regressions[0]);
int trampoline(f_ptr* f) {