Skip to content

Integer overflow with large numbers in LimitIterator #18421

Closed
@chongwick

Description

@chongwick

Description

The following code:

<?php$a = array('zero' => 0, 'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5); //foreach (new ArrayIterator($a) as $k => $v)foreach (newLimitIterator(newArrayIterator($a), PHP_INT_MAX, PHP_INT_MAX) as$k => $v) { var_dump(array($k, $v)); }

Resulted in this output:

/nightly_php/php-src/ext/spl/spl_iterators.c:2137:36: runtime error: signed integer overflow: 9223372036854775807 + 9223372036854775807 cannot be represented in type 'long int' 

But I expected this output instead:

PHP Version

nightly

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    close