[php-src] Issue #18978: Undefined Behavior in `date_sunrise()`
| From: | bendrissou | Date: | Mon, 30 Jun 2025 08:50:20 +0000 |
| Subject: | [php-src] Issue #18978: Undefined Behavior in `date_sunrise()` | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250346@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/18978
Author: bendrissou
### Description
The following code:
```php
<?php
date_sunrise(0, SUNFUNCS_RET_STRING, 61, PHP_FLOAT_MAX);
?>
```
Resulted in this output:
```
Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in /home/bug.php on line 2
Deprecated: Function date_sunrise() is deprecated since 8.1, use date_sun_info() instead in
/home/bug.php on line 2
/home/program/ext/date/lib/astro.c:268:17: runtime error: -nan is outside the range of representable
values of type 'long long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/program/ext/date/lib/astro.c:268:17 in
```
But I expected this output instead:
```
Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in /home/bug.php on line 2
Deprecated: Function date_sunrise() is deprecated since 8.1, use date_sun_info() instead in
/home/bug.php on line 2
```
### PHP Version
```plain
PHP 8.5.0-dev (cli) (built: Jun 4 2025 20:21:49) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.0-dev, Copyright (c) Zend Technologies
```
### Operating System
Ubuntu 20.04