|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14630 integers wrapping around rather than being promoted into floats on overflow
Submitted: 2001-12-20 13:45 UTC Modified: 2002-08-08 01:00 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: markmont at umich dot edu Assigned:
Status: No Feedback Package: Math related
PHP Version: 4.1.0 OS: Solaris 8, 64-bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
35 - 10 = ?
Subscribe to this entry?

 [2001-12-20 13:45 UTC] markmont at umich dot edu
This problem causes all tests in ext/standard/tests/math to fail:

  define('LONG_MAX', is_int(5000000000)? 9223372036854775807
    : 0x7FFFFFFF);
  define('LONG_MIN', -LONG_MAX - 1);
  printf("%d,%d,%d,%d\n",is_int(LONG_MIN  ),is_int(LONG_MAX  ),
  printf( "LONG_MIN = %ld, LONG_MIN - 1 = %ld\n",
    LONG_MIN, LONG_MIN - 1 );
  printf( "LONG_MAX = %ld, LONG_MAX + 1 = %ld\n",
    LONG_MAX, LONG_MAX + 1 );


This script gives the following results on my system:

LONG_MIN = -9223372036854775808, LONG_MIN - 1 = 9223372036854775807
LONG_MAX = 9223372036854775807, LONG_MAX + 1 = -9223372036854775808

Here's my setup:

PHP 4.1.0 compiled as a 64-bit stand-alone interpreter (CGI).

Hardware:  Sun Blade 1000 (750MHz UltraSparc III processor)
OS:        Solaris 8 07/01, running a 64-bit kernel
Compiler:  Sun Forte 6 update 2

env CC="cc -fast -xtarget=generic64" CFLAGS="-v -I/opt/include" \
    CXX="CC -fast -xtarget=generic64 -v" \
    LDFLAGS="-R/opt/lib/sparcv9 -R/opt/lib -L/opt/lib/sparcv9 -L/opt/lib" \
    ac_cv_path_install='/usr/sbin/install' \
  ./configure --prefix=/opt/packages/php-4.1.0 \
    --enable-force-cgi-redirect --enable-discard-path --enable-trans-sid \
    --with-config-file-path=/opt/www/etc \
    --with-exec-dir=/opt/packages/php-4.1.0/bin --with-mm=/opt --with-zlib \
    --with-zlib-dir=/opt --with-expat-dir=/opt --with-mysql --with-gdbm=/opt \
    --with-gd=yes --enable-gd-native-ttf   --with-xpm-dir=/opt \ --with-jpeg-dir=/opt --with-png-dir=/opt --with-freetype-dir=/opt \
I hope this helps.  Any thoughts as to what the problem could be?
If I can be of help in fixing it, just let me know.



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-07 13:31 UTC]
This works fine for me on Linux with the latest development CVS version of PHP (On Linux) provided that you use printf ("LONG_MIN -1 = %f", LONG_MIN - 1); instead, because the value of LONG_MIN - 1 does not fit in a field with %ld.
Can you try this with the latest CVS version, and report back?

 [2002-08-08 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 04 11:01:26 2023 UTC