diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2025-12-07 12:43:44 -0500 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2025-12-08 15:01:05 -0800 |
| commit | 55ea3ec00f5166423cd7dcd67e220cd264a766f6 (patch) | |
| tree | 8fe29d8d55e2c6938bc1f0f5680796354d820cbb /numeric.c | |
| parent | 66bda731901d4588c9df1a671022231ea0d03216 (diff) | |
Fix strict aliasing warning in rb_int128_to_numeric
If we don't have uint128, then rb_int128_to_numeric emits a strict
aliasing warning:
numeric.c:3641:39: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
3641 | return rb_uint128_to_numeric(*(rb_uint128_t*)&n);
| ^~~~~~~~~~~~~~~~~
Diffstat (limited to 'numeric.c')
| -rw-r--r-- | numeric.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -3638,7 +3638,10 @@ rb_int128_to_numeric(rb_int128_t n) } else { // Positive value - return rb_uint128_to_numeric(*(rb_uint128_t*)&n); + union uint128_int128_conversion conversion = { + .int128 = n + }; + return rb_uint128_to_numeric(conversion.uint128); } #endif } |
