-
Notifications
You must be signed in to change notification settings - Fork 8.4k
PowerShell v7 (7.5.4) mis-handles [Int128] overflow #26677
Copy link
Copy link
Open
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Type
Fields
Give feedbackNo fields configured for issues without a type.
Prerequisites
Steps to reproduce
For [Int32] and [Int64] types, overflow is promoted to [Double] (arguably, should be promoted to longer Int types as [Int16] and [Byte] are).
But for [Int128], overflow results in wrong numbers with no type conversion and no overflow error thrown (arguably should be promoted to [BigInt]).
Positive [Int128] overflows to erroneous result (sometimes less than [Int128]::MaxValue, sometimes negative).
Negative [Int128] sometimes overflows to zero, sometimes to [Int128]::MinValue.
("Easy" fix: promote to [Double] as [Int32] and [Int64].)
Demo code:
Expected behavior
[Int128] overflow converted to [Double] or [BigInt] or overflow error thrown.Actual behavior
Incorrect mathematical result is returned for [Int128] overflow.Error details
N/AEnvironment data
Visuals
(Screenshot in "Steps to reproduce" section.)