[php-src] PR #19342: Resolve MSVC C4146 Warning in php_random_uint128.h
| From: | KaseyJenkins | Date: | Fri, 01 Aug 2025 07:56:09 +0000 |
| Subject: | [php-src] PR #19342: Resolve MSVC C4146 Warning in php_random_uint128.h | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-32760@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/19342
Author: KaseyJenkins
The following
[code](https://github.com/php/php-src/blob/master/ext/random/php_random_uint128.h#L124) in
php_random_uint128.h gives out MSVC's
[C4146](https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4146?view=msvc-170)
warning (unary minus operator applied to unsigned type, result still unsigned):
```c
static inline uint64_t php_random_pcgoneseq128xslrr64_rotr64(php_random_uint128_t num)
{
const uint64_t
v = ((uint64_t) (num >> 64U)) ^ (uint64_t) num,
s = num >> 122U;
return (v >> s) | (v << ((-s) & 63));
}
```
This PR resolves it with substituting (-s) with (~s + 1)