From 73339f99c002108f2f2ab57db924a2729f9d87ec Mon Sep 17 00:00:00 2001 From: Ray Rehbein Date: Thu, 11 Oct 2012 19:03:25 +0000 Subject: [PATCH 1/2] 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 --- ext/simplexml/tests/bug54973-32bit.phpt | 24 ++++++++++++++++++++++ ext/simplexml/tests/bug54973-64bit.phpt | 27 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 ext/simplexml/tests/bug54973-32bit.phpt create mode 100644 ext/simplexml/tests/bug54973-64bit.phpt diff --git a/ext/simplexml/tests/bug54973-32bit.phpt b/ext/simplexml/tests/bug54973-32bit.phpt new file mode 100644 index 0000000000000..dda0f7dafe485 --- /dev/null +++ b/ext/simplexml/tests/bug54973-32bit.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #54973 SimpleXML casts intergers wrong. +--SKIPIF-- +214748364800"); +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 diff --git a/ext/simplexml/tests/bug54973-64bit.phpt b/ext/simplexml/tests/bug54973-64bit.phpt new file mode 100644 index 0000000000000..63dc66de627f8 --- /dev/null +++ b/ext/simplexml/tests/bug54973-64bit.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #54973 SimpleXML casts intergers wrong. +--SKIPIF-- +922337203685477580800"); +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-- +9223372036854775808 +800 +800 +800 From 0c779d6d2a5fe59bb88a6b6f5e14201e146c3516 Mon Sep 17 00:00:00 2001 From: Ray Rehbein Date: Fri, 12 Oct 2012 13:17:09 +0000 Subject: [PATCH 2/2] Corrected expected number output to match overflow original number --- ext/simplexml/tests/bug54973-64bit.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/simplexml/tests/bug54973-64bit.phpt b/ext/simplexml/tests/bug54973-64bit.phpt index 63dc66de627f8..a9c0031e7c027 100644 --- a/ext/simplexml/tests/bug54973-64bit.phpt +++ b/ext/simplexml/tests/bug54973-64bit.phpt @@ -21,7 +21,7 @@ echo $strint . "\n"; $double = (double) $xml->number / 1024 / 1024 / 1024 / 1024 / 1024 / 1024; echo $double . "\n"; --EXPECT-- -9223372036854775808 +922337203685477580800 800 800 800