Skip to content

Build failure: cast.c: error: initialization of 'fpos_t (*)(void *, fpos_t, int)' {aka 'long long int (*)(void *, long long int, int)'} from incompatible pointer type #15701

Closed

Description

@barracuda156

Description

Attempt to build PHP with gcc-14 fails due to incompatible pointer types error.

Resulted in this output:

/bin/sh /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/libtool --silent --preserve-dup-deps --tag=CC --mode=compile ccache /opt/local/bin/gcc-mp-14 -Imain/streams/ -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/main/streams/ -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/main -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/ext/date/lib -I/opt/local/include/libxml2 -I/opt/local/include -I/opt/local/include/editline -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/TSRM -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/Zend  -I/opt/local/include -D_GNU_SOURCE  -fno-common -Wstrict-prototypes -Wformat-truncation -Wlogical-op -Wduplicated-cond -Wno-clobbered -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -pipe -Os -arch ppc -ffp-contract=off -fvisibility=hidden -Wimplicit-fallthrough=1 -DZEND_SIGNALS   -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/main/streams/memory.c -o main/streams/memory.lo  -MMD -MF main/streams/memory.dep -MT main/streams/memory.lo
/bin/sh /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/libtool --silent --preserve-dup-deps --tag=CC --mode=compile ccache /opt/local/bin/gcc-mp-14 -Imain/streams/ -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/main/streams/ -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/main -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/ext/date/lib -I/opt/local/include/libxml2 -I/opt/local/include -I/opt/local/include/editline -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/TSRM -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/Zend  -I/opt/local/include -D_GNU_SOURCE  -fno-common -Wstrict-prototypes -Wformat-truncation -Wlogical-op -Wduplicated-cond -Wno-clobbered -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -pipe -Os -arch ppc -ffp-contract=off -fvisibility=hidden -Wimplicit-fallthrough=1 -DZEND_SIGNALS   -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/main/streams/mmap.c -o main/streams/mmap.lo  -MMD -MF main/streams/mmap.dep -MT main/streams/mmap.lo
/bin/sh /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/libtool --silent --preserve-dup-deps --tag=CC --mode=compile ccache /opt/local/bin/gcc-mp-14 -Imain/streams/ -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/main/streams/ -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/main -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/ext/date/lib -I/opt/local/include/libxml2 -I/opt/local/include -I/opt/local/include/editline -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/TSRM -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/Zend  -I/opt/local/include -D_GNU_SOURCE  -fno-common -Wstrict-prototypes -Wformat-truncation -Wlogical-op -Wduplicated-cond -Wno-clobbered -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -pipe -Os -arch ppc -ffp-contract=off -fvisibility=hidden -Wimplicit-fallthrough=1 -DZEND_SIGNALS   -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/main/streams/plain_wrapper.c -o main/streams/plain_wrapper.lo  -MMD -MF main/streams/plain_wrapper.dep -MT main/streams/plain_wrapper.lo
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/main/streams/cast.c:142:9: error: initialization of 'fpos_t (*)(void *, fpos_t,  int)' {aka 'long long int (*)(void *, long long int,  int)'} from incompatible pointer type 'fpos_t (*)(void *, zend_off_t,  int)' {aka 'long long int (*)(void *, int,  int)'} [-Wincompatible-pointer-types]
  142 |         stream_cookie_seeker, stream_cookie_closer
      |         ^~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3/main/streams/cast.c:142:9: note: (near initialization for 'stream_cookie_functions.seeker')
make: *** [main/streams/cast.lo] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3'
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_php/php84/work/php-8.4.0beta3" && /usr/bin/make -j6 -w all 
Exit code: 2

But I expected this output instead:

Build with the current GCC version should succeed.

@ryandesign FYI

PHP Version

PHP 8.4.0beta3

Operating System

macOS 10.6

Activity

  1. added a commit that references this issue on Sep 1, 2024
    64d690b
  2. cmb69 commented on Sep 1, 2024

    @cmb69
    Member

    Is this perhaps related to

    /* Under BSD, emulate fopencookie using funopen */
    #if defined(HAVE_FUNOPEN) && !defined(HAVE_FOPENCOOKIE)
    /* NetBSD 6.0+ uses off_t instead of fpos_t in funopen */
    # if defined(__NetBSD__) && (__NetBSD_Version__ >= 600000000)
    # define PHP_FPOS_T off_t
    # else
    # define PHP_FPOS_T fpos_t
    # endif

  3. cmb69 commented on Nov 9, 2024

    @cmb69
    Member

    'fpos_t (*)(void *, zend_off_t, int)' {aka 'long long int (*)(void *, int, int)'}

    Why is zend_off_t int on this system? It should be int64_t (aka. long int).

    gcc-14
    PHP 8.4.0beta3
    macOS 10.6

    Oh. Really? Putting lipstick on the pig?

    In my opinion, WONTFIX.

  4. barracuda156 commented on Nov 17, 2024

    @barracuda156
    Author

    'fpos_t (*)(void *, zend_off_t, int)' {aka 'long long int (*)(void *, int, int)'}

    Why is zend_off_t int on this system? It should be int64_t (aka. long int).

    The standard does not require long int to be 64 bit and in practice it may not be.
    There is a proper type which is guaranteed to be 64-bit, perhaps rather use that?

    gcc-14
    PHP 8.4.0beta3
    macOS 10.6

    Oh. Really? Putting lipstick on the pig?

    I get your point, but at the same time if the code uses incorrect types, it is a bug, even if it shows up only on a non-standard and seldom used set-up.

  5. jnoordsij commented on Dec 6, 2024

    @jnoordsij

    FYI: I'm seeing what looks to me the same error on Alpine 3.21 (with gcc 14.2) Docker builds (https://github.com/docker-library/php/actions/runs/12180571464/job/34004763272?pr=1552#step:5:1369):

    /usr/src/php/main/streams/cast.c:137:9: error: initialization of 'int (*)(void *, off_t *, int)' {aka 'int (*)(void *, long int *, int)'} from incompatible pointer type 'int (*)(void *, zend_off_t,  int)' {aka 'int (*)(void *, long int,  int)'} [-Wincompatible-pointer-types]
      137 |         stream_cookie_seeker, stream_cookie_closer
          |         ^~~~~~~~~~~~~~~~~~~~
    /usr/src/php/main/streams/cast.c:137:9: note: (near initialization for 'stream_cookie_functions.seek')
    make: *** [Makefile:1812: main/streams/cast.lo] Error 1
    make: *** Waiting for unfinished jobs....
    

    On Alpine 3.20 (with gcc 13.2.1_git20240309-r0) this is only a warning; see https://github.com/docker-library/php/actions/runs/12180571464/job/34004764003?pr=1552#step:5:1343.

    Weirdly enough, it only errs on PHP 8.1 and is fine on >= 8.2; see e.g. https://github.com/docker-library/php/actions/runs/12180571464/job/34004753931?pr=1552#step:5:1481.

  6. cmb69 commented on Dec 6, 2024

    @cmb69
    Member

    'fpos_t (*)(void *, zend_off_t, int)' {aka 'long long int (*)(void *, int, int)'}

    Why is zend_off_t int on this system? It should be int64_t (aka. long int).

    The standard does not require long int to be 64 bit and in practice it may not be.

    There is no standard regarding zend_off_t, and we define it to either int64_t or int32_t:

    php-src/Zend/zend_long.h

    Lines 30 to 51 in 3e2cfdf

    /* Integer types. */
    #ifdef ZEND_ENABLE_ZVAL_LONG64
    typedef int64_t zend_long;
    typedef uint64_t zend_ulong;
    typedef int64_t zend_off_t;
    # define ZEND_LONG_MAX INT64_MAX
    # define ZEND_LONG_MIN INT64_MIN
    # define ZEND_ULONG_MAX UINT64_MAX
    # define Z_L(i) INT64_C(i)
    # define Z_UL(i) UINT64_C(i)
    # define SIZEOF_ZEND_LONG 8
    #else
    typedef int32_t zend_long;
    typedef uint32_t zend_ulong;
    typedef int32_t zend_off_t;
    # define ZEND_LONG_MAX INT32_MAX
    # define ZEND_LONG_MIN INT32_MIN
    # define ZEND_ULONG_MAX UINT32_MAX
    # define Z_L(i) INT32_C(i)
    # define Z_UL(i) UINT32_C(i)
    # define SIZEOF_ZEND_LONG 4
    #endif

    Possibly the following condition is not met:

    php-src/Zend/zend_long.h

    Lines 25 to 28 in 3e2cfdf

    /* This is the heart of the whole int64 enablement in zval. */
    #if defined(__x86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64)
    # define ZEND_ENABLE_ZVAL_LONG64 1
    #endif

    Can you check that @barracuda156? It might even be sufficient to check PHP_INT_SIZE.

    Weirdly enough, it only errs on PHP 8.1 and is fine on >= 8.2; see e.g. https://github.com/docker-library/php/actions/runs/12180571464/job/34004753931?pr=1552#step:5:1481.

    It's quite likely that there had been relevant changes between PHP 8.1 and 8.2. But anyway, PHP-8.1 won't receive regular bugfixes anymore, so this is moot.

  7. github-actions commented on Dec 21, 2024

    @github-actions

    No feedback was provided. The issue is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so. Thank you.

  8. barracuda156 commented on Dec 21, 2024

    @barracuda156
    Author

    @cmb69 From the looks of the macro it should work as intended (gcc should not define __LP64__ on 32-bit ppc), I think, but I can force it locally to either value and compare the effects.

    Upd. In fact, it may need to be:

    /* Integer types. */
    #if ZEND_ENABLE_ZVAL_LONG64
    

    and not ifdef.

  9. cmb69 commented on Dec 21, 2024

    @cmb69
    Member

    Oh, indeed, that is "unclean". In my opinion, it should be either 1/0 (and then checked with plain #if) or defined/undefined (and then checked with #ifdef). To be more robust, there should be an #else branch which either is #define ZEND_ENABLE_ZVAL_LONG64 0 or #undef ZEND_ENABLE_ZVAL_LONG64.

    Now I wonder whether macports defines the macro in some way. Maybe some additional configuration. cc @ryandesign

  10. reopened this on Dec 21, 2024
  11. kc-experian commented on Jan 31, 2025

    @kc-experian

    I needed to compile an old version of PHP for a specific use and I came across this error. Analyzing the code I was able to identify that the problem occurs in versions above 8.1 due to a change in this part of main/streams/cast.c.
    I made a patch to make it compatible with this change and the code compiled without errors.

    # ifdef COOKIE_SEEKER_USES_OFF64_T
    static int stream_cookie_seeker(void *cookie, off64_t *position, int whence)
    # else
    static int stream_cookie_seeker(void *cookie, off_t *position, int whence)
    # endif
    {
    
    	*position = php_stream_seek((php_stream *)cookie, (zend_off_t)*position, whence);
    
    	if (*position == -1) {
    		return -1;
    	}
    	return 0;
    }
    
  12. barracuda156 commented on Mar 14, 2026

    @barracuda156
    Author

    @kc-experian Maybe make a PR?

    Upd. I guess it was already committed.
    Upd2. Nah, still broken.

  13. barracuda156 commented on Mar 14, 2026

    @barracuda156
    Author

    The error is here, apparently:

    static PHP_FPOS_T stream_cookie_seeker(void *cookie, zend_off_t position, int whence)

  14. barracuda156 commented on Jul 16, 2026

    @barracuda156
    Author

    The fix remains needed with current release of php 8.5 at least.

  15. Girgias commented on Sep 16, 2026

    @Girgias
    Member

    @petk do you maybe have some insight here on how to address this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions