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-13564] ObjectIdentifier's equal has an unexpected result #56002

swift-ci opened this issue Sep 18, 2020 · 3 comments

[SR-13564] ObjectIdentifier's equal has an unexpected result #56002

swift-ci opened this issue Sep 18, 2020 · 3 comments


Copy link

@swift-ci swift-ci commented Sep 18, 2020

Previous ID SR-13564
Radar rdar://problem/69169351
Original Reporter 酷酷的哀殿 (JIRA User)
Type Bug

Attachment: Download

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

md5: b66954dda298d0c551eb157c90071d53

Issue Description:

    func makeIdentifier(input: Int) -> ObjectIdentifier {
    let a = makeIdentifier(input: Int.min);
    let b = makeIdentifier(input: Int.max);
    print(a == b) // print: true

we expected it is false


The first IntegerRef will be free after ObjectIdentifier.init, so the second will use the same heap memory.

Copy link

@typesanitizer typesanitizer commented Sep 18, 2020

@swift-ci create

Copy link
Collaborator Author

@swift-ci swift-ci commented Oct 15, 2020

Comment by Kyle Macomber (JIRA)

We should document that ObjectIdentifier are only unique while the object is alive.

Copy link

@lorentey lorentey commented Oct 17, 2020

ObjectIdentifier is only guaranteed unique as long as the underlying object exists – when the instance gets deallocated, its object identifier may be reused for a different object. (Internally, objects are identified by their memory location.)

This works as intended, although the documentation ought to describe this fact.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants