Too big `string` to `int` cast results nonsense
オープン
まだ誰も着手していません。
Bug
Status: Needs Triage
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
<?php
if ( (string) PHP_INT_MAX === '9223372036854775808' ) {
echo "string identical" . PHP_EOL;
}
if ( PHP_INT_MAX === (int) '9223372036854775808' ) {
echo "int identical" . PHP_EOL;
}
Resulted in this output:
int identical
But I expected this output instead:
Deprecated: Conversion from string '9223372036854775808' to int loses precision
A very similar error already exists when converting float to int implicitly e.g. $a[ PHP_INT_MAX + 1 ] = '';
See also https://github.com/php/php-src/issues/17081 which reports that for float/int casts
PHP Version
PHP 8.4.8
Operating System
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
PHP 8.4.8 で string から int へのキャスト動作を再現し、その後、PHP インタープリターの string から整数への変換経路を追跡します。issue で参照されている、既存の float から int への変換における精度損失の処理と比較します。サイズが大きすぎる string の変換で、何も通知せずに PHP_INT_MAX を生成するのではなく、期待される deprecation が報告されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100