Skip to content

Commit

Permalink
tests for argument passing of fixed arrays of pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
wlav committed Oct 23, 2021
1 parent 6dfb4b6 commit 297f557
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ master: 2.2.0
* Get proper shape of ``void*`` and enum arrays
* Fix access to (const) ref data members
* Fix sometimes PCH uninstall issue
* Fix argument passing of fixed arrays of pointers


2021-07-17: 2.1.0
Expand Down
24 changes: 24 additions & 0 deletions test/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,3 +1040,27 @@ def test36_ctypes_sizeof(self):

assert cppyy.sizeof(param) == ctypes.sizeof(param)

def test37_array_of_pointers_argument(self):
"""Passing an array of pointers used to crash"""

import cppyy
import cppyy.ll

cppyy.cppdef("""\
namespace ArrayOfPointers {
void* test(int *arr[8], bool is_int=true) { return is_int ? (void*)arr : nullptr; }
void* test(uint8_t *arr[8], bool is_int=false) { return is_int ? nullptr : (void*)arr; }
}""")

ns = cppyy.gbl.ArrayOfPointers

N = 9

for t, b in (('int*', True), ('uint8_t*', False)):
arr = cppyy.ll.array_new[t](N, managed=True)
assert arr.shape[0] == N
assert len(arr) == N

res = ns.test(arr, b)

assert cppyy.addressof(res) == cppyy.addressof(arr)

0 comments on commit 297f557

Please sign in to comment.