Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions ext/simplexml/tests/bug54973-32bit.phpt
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions ext/simplexml/tests/bug54973-64bit.phpt
Original file line number Diff line number Diff line change
@@ -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