mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Add test with misaligned allocation
This commit is contained in:
parent
3372d4fe9b
commit
35c71f1b47
|
@ -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)
|
||||
|
|
|
@ -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
|
|
@ -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[]
|
||||
= { ®ression_1008, ®ression_1000, ®ression_1067, ®ression_1072, ®ression_1087, ®ression_1095, ®ression_1096, ®ression_1149 };
|
||||
= { ®ression_1008, ®ression_1000, ®ression_1067, ®ression_1072, ®ression_1087, ®ression_1095, ®ression_1096, ®ression_1149, ®ression_XXXX };
|
||||
static const int regression_tests_sizeof_regressions = sizeof(regression_tests_regressions) / sizeof(regression_tests_regressions[0]);
|
||||
|
||||
int trampoline(f_ptr* f) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user