Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-2938] Random SwiftShims functionality not working on Linux #45532

Closed
colemancda opened this issue Oct 13, 2016 · 2 comments
Closed

[SR-2938] Random SwiftShims functionality not working on Linux #45532

colemancda opened this issue Oct 13, 2016 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@colemancda
Copy link
Contributor

Previous ID SR-2938
Radar None
Original Reporter @colemancda
Type Bug
Status Closed
Resolution Won't Do
Environment

Ubuntu 14.04 LTS with Swift 3.0 Release

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: 1eacea1891d48d8fd5267afda8e5bfb7

Issue Description:

_swift_stdlib_cxx11_mt19937_uniform is not generating a random value on Linux.

Code for testing:

// Import standard C library
#if os(macOS) || os(iOS)
import Darwin.C
#else
import SwiftShims
import Glibc
#endif

let upperBound: UInt32 = 10

let randomValue: UInt32

#if os(Linux)
randomValue = _swift_stdlib_cxx11_mt19937_uniform(upperBound)
#else
randomValue = arc4random_uniform(upperBound)
#endif

print("Random number:", randomValue)

@belkadan
Copy link
Contributor

cc @airspeedswift

@airspeedswift
Copy link
Member

This is present only for Swift std lib unit testing purposes and is not meant to be called directly (hence the _ at the start). It needs seeding before it generates random numbers.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants