xref: /php-src/ext/ffi/tests/nested_addr.phpt (revision d4ad9b72)
1--TEST--
2FFI Cannot nest FFI::addr() calls
3--EXTENSIONS--
4ffi
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9$ffi = \FFI::cdef(<<<'CPP'
10typedef struct {
11    int8_t bar;
12} Foo;
13CPP);
14
15$struct = $ffi->new('Foo');
16$structPtrPtr = \FFI::addr(\FFI::addr($struct));
17?>
18--EXPECTF--
19Fatal error: Uncaught FFI\Exception: FFI::addr() cannot create a reference to a temporary pointer in %s:%d
20Stack trace:
21#0 %s(%d): FFI::addr(Object(FFI\CData:struct <anonymous>*))
22#1 {main}
23  thrown in %s on line %d
24