Skip to content

Loading…

Copied reproduction code from bugs.php.net to phpt #213

Closed
wants to merge 2 commits into from

4 participants

@rrehbeindoi

Original code submitted by bphelpsen at gmail dot com
Modified to handle testing on 64-bit systems in addition to the original 32-bit

@rrehbeindoi rrehbeindoi Copied reproduction code from bugs.php.net to phpt
Original code submitted by bphelpsen at gmail dot com
Modified to handle testing on 64-bit systems in addition to the original 32-bit
73339f9
@laruence
php.net member

bug54973-64bit.phpt failed for me:

001+ 922337203685477580800
002+ 8
001- 9223372036854775808
004- 800

@rrehbeindoi

Good catch. thank you.

@dsp
php.net member

Without looking into the exact details of the bugs, it seems that it's not yet clear if it's a simplexml bug or a engine thing. As soon as we decide on that we can go ahead and merge the test, but for now I leave it unmerged.

@dsp dsp was assigned
@php-pulls

Comment on behalf of stas at php.net:

Should be added when the bug is fixed, so I'm adding this code to the bug but closing this pull until the bug fix is ready.

@php-pulls php-pulls closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 11, 2012
  1. @rrehbeindoi

    Copied reproduction code from bugs.php.net to phpt

    rrehbeindoi committed
    Original code submitted by bphelpsen at gmail dot com
    Modified to handle testing on 64-bit systems in addition to the original 32-bit
Commits on Oct 12, 2012
  1. @rrehbeindoi
This page is out of date. Refresh to see the latest.
Showing with 51 additions and 0 deletions.
  1. +24 −0 ext/simplexml/tests/bug54973-32bit.phpt
  2. +27 −0 ext/simplexml/tests/bug54973-64bit.phpt
View
24 ext/simplexml/tests/bug54973-32bit.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #54973 SimpleXML casts intergers wrong.
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
+--FILE--
+<?php
+
+$xml = simplexml_load_string("<xml><number>214748364800</number></xml>");
+echo $xml->number . "\n"; // the proper number
+
+$int = $xml->number / 1024 / 1024 / 1024; // initial cast to an int causes problems
+echo $int . "\n";
+
+$strint = strval($xml->number) / 1024 / 1024 / 1024; // external cast to int behavior
+echo $strint . "\n";
+
+$double = (double) $xml->number / 1024 / 1024 / 1024; // hard cast to a double fixes it
+echo $double . "\n";
+--EXPECT--
+214748364800
+200
+200
+200
View
27 ext/simplexml/tests/bug54973-64bit.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #54973 SimpleXML casts intergers wrong.
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
+--FILE--
+<?php
+
+$xml = simplexml_load_string("<xml><number>922337203685477580800</number></xml>");
+echo $xml->number . "\n"; // the proper number
+
+// initial cast to an int causes problems
+$int = $xml->number / 1024 / 1024 / 1024 / 1024 / 1024 / 1024;
+echo $int . "\n";
+
+// external cast to int behavior
+$strint = strval($xml->number) / 1024 / 1024 / 1024 / 1024 / 1024 / 1024;
+echo $strint . "\n";
+
+// hard cast to a double fixes it
+$double = (double) $xml->number / 1024 / 1024 / 1024 / 1024 / 1024 / 1024;
+echo $double . "\n";
+--EXPECT--
+922337203685477580800
+800
+800
+800
Something went wrong with that request. Please try again.