Skip to content

[SR-8798] BinaryFloatingPoint.random(in:) crashes on some valid ranges #51306

Open
@hartbit

Description

@hartbit
Previous ID SR-8798
Radar None
Original Reporter @hartbit
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: e4ed61953fff624b3e51c4a4dfb662dd

Issue Description:

The following piece of code crashes at runtime:

extension BinaryFloatingPoint where Self.RawSignificand: FixedWidthInteger {
    static func random() -> Self {
        return random(in: -greatestFiniteMagnitude..<greatestFiniteMagnitude)
    }
} 

Because of https://github.com/apple/swift/blob/cffe3869a678c62a5d9369fe90a07905cd1d6f07/stdlib/public/core/FloatingPoint.swift.gyb#L2440

This should be fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwarenumericsArea → standard library: Numeric APIstandard libraryArea: Standard library umbrellaswift 6.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions