Skip to content

Commit d479c63

Browse files
committed
Fix miscellaneous test failures/BORKED
The libxml borked warning was unrelated Fix 32-bit builds and soap tests. Make it so the same warnings would be emitted both for 32-bit and 64-bit builds
1 parent f77650a commit d479c63

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

Zend/tests/binary-32bit.phpt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ var_dump(-0b11111111111111111111111111111111);
7777
var_dump(-0b1111111111111111111111111111111);
7878
var_dump(-0b111111111111111111111111111111);
7979
var_dump(-0b1);
80-
--EXPECT--
80+
--EXPECTF--
81+
Warning: Saw imprecise float binary literal - the last 11 non-zero bits were truncated in %sbinary-32bit.php on line 65
82+
83+
Warning: Saw imprecise float binary literal - the last 11 non-zero bits were truncated in %sbinary-32bit.php on line 67
8184
int(1)
8285
int(3)
8386
int(7)
@@ -149,4 +152,4 @@ float(-8589934591)
149152
float(-4294967295)
150153
int(-2147483647)
151154
int(-1073741823)
152-
int(-1)
155+
int(-1)

Zend/tests/binary_overflow_number.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Octal overflow in numeric literal warning
55
// rounding down
66
var_dump(eval('return 0b1011111111111111111111111111111111111111111111111111100000000000;'));
77
var_dump(eval('return 0b1011111111111111111111111111111111111111111111111111100000000001;'));
8-
// rounding up
8+
echo "test rounding up\n";
99
var_dump(eval('return 0b1011111111111111111111111111111111111111111111111111111111111111;'));
1010
var_dump(eval('return 0b1011111111111111111111111111111111111111111111111111110000000000;'));
1111
var_dump(eval('return 0b1011111111111111111111111111111111111111111111111111111000000000;'));
12-
// don't count _ or leading 0s
12+
echo "test don't count _ or leading 0s\n";
1313
var_dump(eval('return 0b111_111_111_111_111_111_111_111_111_111_111_111_111_111_111_111_111_111_000_000_000_0;'));
1414
var_dump(eval('return 0b000_111_111_111_111_111_111_111_111_111_111_111_111_111_111_111_111_111_111_000_000_000_0;'));
1515
var_dump(eval('return 0b1111111111111111111111111111111111111111111111111111111111111111;'));
@@ -19,6 +19,7 @@ float(1.383505805528216E+19)
1919

2020
Warning: Saw imprecise float binary literal - the last 11 non-zero bits were truncated in %sbinary_overflow_number.php(4) : eval()'d code on line 1
2121
float(1.383505805528216E+19)
22+
test rounding up
2223
2324
Warning: Saw imprecise float binary literal - the last 11 non-zero bits were truncated in %sbinary_overflow_number.php(6) : eval()'d code on line 1
2425
float(1.3835058055282164E+19)
@@ -28,6 +29,7 @@ float(1.3835058055282164E+19)
2829
2930
Warning: Saw imprecise float binary literal - the last 2 non-zero bits were truncated in %sbinary_overflow_number.php(8) : eval()'d code on line 1
3031
float(1.3835058055282164E+19)
32+
test don't count _ or leading 0s
3133

3234
Warning: Saw imprecise float binary literal - the last 1 non-zero bits were truncated in %sbinary_overflow_number.php(10) : eval()'d code on line 1
3335
float(1.844674407370955E+19)

Zend/tests/hex_overflow_32bit.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ foreach ($doubles as $d) {
2222
echo "Done\n";
2323
?>
2424
--EXPECTF--
25+
Warning: Saw imprecise float hex literal - the last 19 non-zero bits were truncated in %shex_overflow_32bit.php on line 5
26+
27+
Warning: Saw imprecise float hex literal - the last 51 non-zero bits were truncated in %shex_overflow_32bit.php on line 6
28+
29+
Warning: Saw imprecise float hex literal - the last 38 non-zero bits were truncated in %shex_overflow_32bit.php on line 7
2530
float(4.0833602971%dE+14)
2631
float(4.7223664828%dE+21)
2732
float(1.3521606402%dE+31)

Zend/zend_language_scanner.l

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,14 +2033,15 @@ NEWLINE ("\r"|"\n"|"\r\n")
20332033
RETURN_TOKEN_WITH_VAL(T_LNUMBER);
20342034
} else {
20352035
const char* last_one_bit = bin + len - 1;
2036+
ZVAL_DOUBLE(zendlval, zend_bin_strtod(bin, (const char **)&end));
2037+
ZEND_ASSERT(end == bin + len);
20362038
while (*last_one_bit == '0') {
20372039
last_one_bit--;
20382040
ZEND_ASSERT(last_one_bit > bin);
20392041
}
2040-
ZVAL_DOUBLE(zendlval, zend_bin_strtod(bin, (const char **)&end));
20412042
/* errno isn't checked since we allow HUGE_VAL/INF overflow */
2042-
ZEND_ASSERT(end == bin + len);
2043-
if (last_one_bit - bin + 1> 53) {
2043+
/* TODO: Cross-platform macro for 64-bit double */
2044+
if (last_one_bit - bin + 1 > 53 && (SIZEOF_ZEND_LONG >= 8 || Z_DVAL_P(zendlval) >= (double)0x8000000000000000ULL)) {
20442045
zend_error(E_COMPILE_WARNING, "Saw imprecise float binary literal - the last %zu non-zero bits were truncated", (size_t)(last_one_bit - bin + 1 - 53));
20452046
}
20462047
if (contains_underscores) {
@@ -2097,7 +2098,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
20972098
errno = 0;
20982099
if (is_octal) { /* octal overflow */
20992100
ZVAL_DOUBLE(zendlval, zend_oct_strtod(lnum, (const char **)&end));
2100-
if (!is_truncated) {
2101+
if (!is_truncated && (SIZEOF_ZEND_LONG >= 8 || Z_DVAL_P(zendlval) >= (double)0x8000000000000000ULL)) {
21012102
size_t bits_in_representation = bits_in_octal_representation(lnum, len);
21022103
if (bits_in_representation > 53) {
21032104
zend_error(E_COMPILE_WARNING, "Saw imprecise float octal literal - the last %zu non-zero bits were truncated", bits_in_representation - 53);
@@ -2153,12 +2154,14 @@ NEWLINE ("\r"|"\n"|"\r\n")
21532154
}
21542155
RETURN_TOKEN_WITH_VAL(T_LNUMBER);
21552156
} else {
2156-
size_t bits_in_representation = bits_in_hex_representation(hex, len);
21572157
ZVAL_DOUBLE(zendlval, zend_hex_strtod(hex, (const char **)&end));
21582158
/* errno isn't checked since we allow HUGE_VAL/INF overflow */
21592159
ZEND_ASSERT(end == hex + len);
2160-
if (bits_in_representation > 53) {
2161-
zend_error(E_COMPILE_WARNING, "Saw imprecise float hex literal - the last %zu non-zero bits were truncated", bits_in_representation - 53);
2160+
if (SIZEOF_ZEND_LONG >= 8 || Z_DVAL_P(zendlval) >= (double)0x8000000000000000ULL) {
2161+
size_t bits_in_representation = bits_in_hex_representation(hex, len);
2162+
if (bits_in_representation > 53) {
2163+
zend_error(E_COMPILE_WARNING, "Saw imprecise float hex literal - the last %zu non-zero bits were truncated", bits_in_representation - 53);
2164+
}
21622165
}
21632166
if (contains_underscores) {
21642167
efree(hex);

ext/libxml/tests/bug79191.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Bug #79191 (Error in SoapClient ctor disables DOMDocument::save())
33
--SKIPIF--
44
<?php
55
if (!extension_loaded('soap')) die('skip soap extension not available');
6-
if (!extension_loaded('dom')) die('dom extension not available');
6+
if (!extension_loaded('dom')) die('skip dom extension not available');
77
?>
88
--FILE--
99
<?php

0 commit comments

Comments
 (0)