Skip to content

Use a Myers Singleton for null #490

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

Merged
merged 2 commits into from
Jun 27, 2016
Merged

Use a Myers Singleton for null #490

merged 2 commits into from
Jun 27, 2016

Conversation

cdunn2001
Copy link
Contributor

Avoid some static initialization problems.

From @marklakata
See #488

@BillyGoto
Copy link

This singleton pattern breaks if the object has a destructor. There is a
destructor-order problem that's a dual of the init-order problem.

So I'd go with an intentionally "leaked" heap-allocated object.

const Value& nullSingleton() {
static const Value* p = new Value;
return *p;
}

On Sunday, June 26, 2016, Christopher Dunn notifications@github.com wrote:

Avoid some static initialization problems.

From @marklakata https://github.com/marklakata

See #488 #488

You can view, comment on, or merge this pull request online at:

#490
Commit Summary

  • Use a Myers Singleton for null

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#490, or mute the
thread
https://github.com/notifications/unsubscribe/AHFzPCLZAn7WplXL-Gpt253U90SGNGJJks5qPxBBgaJpZM4I-rG9
.

ǝnɥɐuop ʎllıq

Avoid some static initialization problems.

From @marklakata
See #488
@cdunn2001
Copy link
Contributor Author

Interesting. I would never have thought of that.

Without objection, I'll do a micro-version bump with this. Also on 0.10.*.

@cdunn2001 cdunn2001 merged commit 7e4df50 into master Jun 27, 2016
@cdunn2001 cdunn2001 deleted the null-singleton branch June 27, 2016 05:12
cdunn2001 added a commit that referenced this pull request Jul 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants