xref: /PHP-8.1/ext/ffi/tests/bug79096.phpt (revision bd9f4fa6)
1--TEST--
2Bug #79096 (FFI Struct Segfault)
3--EXTENSIONS--
4ffi
5zend_test
6--FILE--
7<?php
8require_once('utils.inc');
9$header = <<<HEADER
10struct bug79096 {
11    uint64_t a;
12    uint64_t b;
13};
14
15struct bug79096 bug79096(void);
16HEADER;
17
18if (PHP_OS_FAMILY !== 'Windows') {
19    $ffi = FFI::cdef($header);
20} else {
21    try {
22        $ffi = FFI::cdef($header, 'php_zend_test.dll');
23    } catch (FFI\Exception $ex) {
24        $ffi = FFI::cdef($header, ffi_get_php_dll_name());
25    }
26}
27
28$struct = $ffi->bug79096();
29var_dump($struct);
30?>
31--EXPECTF--
32object(FFI\CData:struct bug79096)#%d (2) {
33  ["a"]=>
34  int(1)
35  ["b"]=>
36  int(1)
37}
38