@@ -270,13 +270,28 @@ START_TEST(test_take1_offset) {
270270}
271271END_TEST
272272
273+ START_TEST (test_reshape_0 ) {
274+ /* This tests that we don't segfault when reshaping 0-sized arrays */
275+ const size_t odims [3 ] = {24 , 0 , 33 };
276+ const size_t ndims1 [3 ] = {0 , 24 , 33 };
277+ const size_t ndims2 [3 ] = {24 , 33 , 0 };
278+
279+ GpuArray v ;
280+ ga_assert_ok (GpuArray_empty (& v , ctx , GA_FLOAT , 3 , odims , GA_C_ORDER ));
281+ ga_assert_ok (GpuArray_reshape_inplace (& v , 3 , ndims1 , GA_ANY_ORDER ));
282+ ga_assert_ok (GpuArray_reshape_inplace (& v , 3 , odims , GA_ANY_ORDER ));
283+ ga_assert_ok (GpuArray_reshape_inplace (& v , 3 , ndims2 , GA_ANY_ORDER ));
284+ }
285+ END_TEST
286+
273287Suite * get_suite (void ) {
274288 Suite * s = suite_create ("array" );
275289 TCase * tc = tcase_create ("take1" );
276290 tcase_add_checked_fixture (tc , setup , teardown );
277291 tcase_set_timeout (tc , 8.0 );
278292 tcase_add_test (tc , test_take1_ok );
279293 tcase_add_test (tc , test_take1_offset );
294+ tcase_add_test (tc , test_reshape_0 );
280295 suite_add_tcase (s , tc );
281296 return s ;
282297}
0 commit comments