File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -2535,7 +2535,11 @@ int verify_include(void *buffer)
25352535
25362536int test_struct_buffer (flatcc_builder_t * B )
25372537{
2538- uint8_t buffer [100 ];
2538+ /* Allocate a buffer and make sure it's aligned on targets that don't
2539+ * use a 16 bytes stack alignment (e.g. 32-bit/x86 and s390x).
2540+ * This will avoid an undefined behaviour in this testcase:
2541+ * "member access within misaligned address". */
2542+ alignas(16 ) uint8_t buffer [100 ];
25392543
25402544 size_t size ;
25412545 ns (Vec3_t ) * v ;
@@ -2584,7 +2588,11 @@ int test_struct_buffer(flatcc_builder_t *B)
25842588
25852589int test_typed_struct_buffer (flatcc_builder_t * B )
25862590{
2587- uint8_t buffer [100 ];
2591+ /* Allocate a buffer and make sure it's aligned on targets that don't
2592+ * use a 16 bytes stack alignment (e.g. 32-bit/x86 and s390x).
2593+ * This will avoid an undefined behaviour in this testcase:
2594+ * "member access within misaligned address". */
2595+ alignas(16 ) uint8_t buffer [100 ];
25882596
25892597 size_t size ;
25902598 ns (Vec3_t ) * v ;
You can’t perform that action at this time.
0 commit comments