Skip to content

Commit f754909

Browse files
committed
Pass actual string for float-string
1 parent 7f6e025 commit f754909

File tree

9 files changed

+22
-22
lines changed

9 files changed

+22
-22
lines changed

Zend/tests/type_coercion/float_to_int/explicit_casts_should_not_warn.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ int(0)
4040
int(3)
4141
int(3)
4242

43-
Warning: The float-string 1.0E+121 is not representable as an int, cast occurred in %s on line %d
43+
Warning: The float-string "1.0E+121" is not representable as an int, cast occurred in %s on line %d
4444
int(9223372036854775807)
4545

46-
Warning: The float-string 1.0E+301 is not representable as an int, cast occurred in %s on line %d
46+
Warning: The float-string "1.0E+301" is not representable as an int, cast occurred in %s on line %d
4747
int(9223372036854775807)
4848
int(0)

Zend/tests/type_coercion/float_to_int/non-rep-float-as-int-extra1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ var_dump($b | 1);
1414

1515
?>
1616
--EXPECTF--
17-
The float-string 1.0E+4%d is not representable as an int, cast occurred
17+
The float-string "1.0E+4%d" is not representable as an int, cast occurred
1818
Implicit conversion from float-string "1.0E+4%d" to int loses precision
1919
int(%d)

Zend/tests/type_coercion/float_to_int/warning_float_does_not_fit_zend_long_arrays.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var_dump($array[$string_float]);
2626
Warning: The float 1.0E+121 is not representable as an int, cast occurred in %s on line %d
2727
int(0)
2828

29-
Warning: The float-string 1.0E+121 is not representable as an int, cast occurred in %s on line %d
29+
Warning: The float-string "1.0E+121" is not representable as an int, cast occurred in %s on line %d
3030
bool(true)
3131

3232
Warning: The float 1.0E+121 is not representable as an int, cast occurred in %s on line %d

Zend/tests/type_coercion/float_to_int/warning_float_does_not_fit_zend_long_strings.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var_dump($string);
7878
Warning: The float 1.0E+121 is not representable as an int, cast occurred in %s on line %d
7979
int(0)
8080

81-
Warning: The float-string 1.0E+121 is not representable as an int, cast occurred in %s on line %d
81+
Warning: The float-string "1.0E+121" is not representable as an int, cast occurred in %s on line %d
8282
int(9223372036854775807)
8383
Attempt to read
8484
Float

Zend/zend_operators.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval *
431431
/* zend_dval_to_lval_cap() can emit a warning so always do the copy here */
432432
op_str = zend_string_copy(Z_STR_P(op));
433433
}
434-
lval = zend_dval_to_lval_cap(dval);
434+
lval = zend_dval_to_lval_cap(dval, op_str);
435435
if (!zend_is_long_compatible(dval, lval)) {
436436
zend_incompatible_string_to_long_error(op_str);
437437
if (UNEXPECTED(EG(exception))) {
@@ -918,9 +918,9 @@ ZEND_API void ZEND_COLD zend_oob_double_to_long_error(double d)
918918
{
919919
zend_error_unchecked(E_WARNING, "The float %.*H is not representable as an int, cast occurred", -1, d);
920920
}
921-
ZEND_API void ZEND_COLD zend_oob_string_to_long_error(double d)
921+
ZEND_API void ZEND_COLD zend_oob_string_to_long_error(const zend_string *s)
922922
{
923-
zend_error_unchecked(E_WARNING, "The float-string %.*H is not representable as an int, cast occurred", -1, d);
923+
zend_error_unchecked(E_WARNING, "The float-string \"%s\" is not representable as an int, cast occurred", ZSTR_VAL(s));
924924
}
925925

926926
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(const zval *op, bool is_strict) /* {{{ */
@@ -963,7 +963,7 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(const zval *op, bool is_stri
963963
* behaviour.
964964
*/
965965
/* Most usages are expected to not be (int) casts */
966-
lval = zend_dval_to_lval_cap(dval);
966+
lval = zend_dval_to_lval_cap(dval, Z_STR_P(op));
967967
if (UNEXPECTED(is_strict)) {
968968
if (!zend_is_long_compatible(dval, lval)) {
969969
zend_incompatible_string_to_long_error(Z_STR_P(op));

Zend/zend_operators.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const
118118
ZEND_API void zend_incompatible_double_to_long_error(double d);
119119
ZEND_API void zend_incompatible_string_to_long_error(const zend_string *s);
120120
ZEND_API void ZEND_COLD zend_oob_double_to_long_error(double d);
121-
ZEND_API void ZEND_COLD zend_oob_string_to_long_error(double d);
121+
ZEND_API void ZEND_COLD zend_oob_string_to_long_error(const zend_string *s);
122122

123123
ZEND_API zend_long ZEND_FASTCALL zend_dval_to_lval_slow(double d);
124124

@@ -145,13 +145,13 @@ static zend_always_inline zend_long zend_dval_to_lval_silent(double d)
145145
}
146146

147147
/* Used to convert a string float to integer during an (int) cast */
148-
static zend_always_inline zend_long zend_dval_to_lval_cap(double d)
148+
static zend_always_inline zend_long zend_dval_to_lval_cap(double d, const zend_string *s)
149149
{
150150
if (UNEXPECTED(!zend_finite(d))) {
151-
zend_oob_string_to_long_error(d);
151+
zend_oob_string_to_long_error(s);
152152
return 0;
153153
} else if (!ZEND_DOUBLE_FITS_LONG(d)) {
154-
zend_oob_string_to_long_error(d);
154+
zend_oob_string_to_long_error(s);
155155
return (d > 0 ? ZEND_LONG_MAX : ZEND_LONG_MIN);
156156
}
157157
return (zend_long)d;

ext/dom/php_dom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,7 @@ static bool dom_nodemap_or_nodelist_process_offset_as_named(zval *offset, zend_l
22612261
if (0 == (is_numeric_string_type = is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), lval, &dval, true))) {
22622262
return true;
22632263
} else if (is_numeric_string_type == IS_DOUBLE) {
2264-
*lval = zend_dval_to_lval_cap(dval);
2264+
*lval = zend_dval_to_lval_cap(dval, Z_STR_P(offset));
22652265
}
22662266
} else {
22672267
*lval = zval_get_long(offset);

ext/standard/tests/general_functions/gettype_settype_variation2.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ int(1)
274274
string(7) "integer"
275275
-- Iteration 20 --
276276
string(6) "string"
277-
2: The float-string 2.974394749328742E+21 is not representable as an int, cast occurred
277+
2: The float-string "2974394749328742328432" is not representable as an int, cast occurred
278278
bool(true)
279279
int(2147483647)
280280
string(7) "integer"
@@ -305,7 +305,7 @@ int(1)
305305
string(7) "integer"
306306
-- Iteration 26 --
307307
string(6) "string"
308-
2: The float-string 2.974394749328742E+21 is not representable as an int, cast occurred
308+
2: The float-string "2974394749328742328432" is not representable as an int, cast occurred
309309
bool(true)
310310
int(2147483647)
311311
string(7) "integer"
@@ -675,7 +675,7 @@ int(1)
675675
string(7) "integer"
676676
-- Iteration 20 --
677677
string(6) "string"
678-
2: The float-string 2.974394749328742E+21 is not representable as an int, cast occurred
678+
2: The float-string "2974394749328742328432" is not representable as an int, cast occurred
679679
bool(true)
680680
int(2147483647)
681681
string(7) "integer"
@@ -706,7 +706,7 @@ int(1)
706706
string(7) "integer"
707707
-- Iteration 26 --
708708
string(6) "string"
709-
2: The float-string 2.974394749328742E+21 is not representable as an int, cast occurred
709+
2: The float-string "2974394749328742328432" is not representable as an int, cast occurred
710710
bool(true)
711711
int(2147483647)
712712
string(7) "integer"

ext/standard/tests/general_functions/intval.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,18 @@ int(2147483647)
222222

223223
*** Testing intval() on non integer types ***
224224

225-
Warning: The float-string -2147483649 is not representable as an int, cast occurred in %s on line %d
225+
Warning: The float-string "-2147483649" is not representable as an int, cast occurred in %s on line %d
226226
int(-2147483648)
227227

228-
Warning: The float-string 2147483648 is not representable as an int, cast occurred in %s on line %d
228+
Warning: The float-string "2147483648" is not representable as an int, cast occurred in %s on line %d
229229
int(2147483647)
230230
int(0)
231231
int(0)
232232

233-
Warning: The float-string 20000000001 is not representable as an int, cast occurred in %s on line %d
233+
Warning: The float-string "20000000001" is not representable as an int, cast occurred in %s on line %d
234234
int(2147483647)
235235

236-
Warning: The float-string -20000000001 is not representable as an int, cast occurred in %s on line %d
236+
Warning: The float-string "-20000000001" is not representable as an int, cast occurred in %s on line %d
237237
int(-2147483648)
238238
int(0)
239239
int(0)

0 commit comments

Comments
 (0)