|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39301 ip2long returns unsigned on x86_64 (buggy RETURN_LONG?)
Submitted: 2006-10-30 01:12 UTC Modified: 2006-10-30 09:28 UTC
From: fly2k at bk dot ru Assigned:
Status: Not a bug Package: Network related
PHP Version: 5.1.6 OS: N/A
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: fly2k at bk dot ru
New email:
PHP Version: OS:


 [2006-10-30 01:12 UTC] fly2k at bk dot ru

Must print -2 as documented. But on x86_64 returns 4294967294.

Tried on two different hosts - one athlon64 with gentoo, other athlon64 with FC.

Reproduce code:

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-30 07:57 UTC] judas dot iscariote at gmail dot com
actually this is the expected behavior. to obtain the correct result, to what the documentation clearly states.

use the "%u" formatter of sprintf() or printf().

and then you will get the correct result both arch
 [2006-10-30 08:42 UTC]
 [2006-10-30 09:28 UTC] fly2k at bk dot ru
Can't agree... quote from

Because PHP's integer type is signed, and many IP addresses will result in negative integers, you need to use the "%u" formatter of sprintf() or printf() to get the string representation of the unsigned IP address.

So, interger type is signed, results may be signed, and _IF_I_NEED_ unsigned, I will use %u or so... But what if I dont need and signed is ok for me? I want signed value but on x86_64 I gets unsigned... In any case, any function must return same result for same parameter at any platform, is not?
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Dec 01 07:05:54 2022 UTC