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

Use pointer_traits.to_address instead of addressof(*p) #5

Closed
wants to merge 1 commit into
base: develop
from

Conversation

Projects
None yet
2 participants
@glenfe
Member

glenfe commented May 29, 2017

addressof(*p) before calling construct() is technically undefined as there is no object yet constructed in the storage aliased by p (given that addressof() takes an l-value reference).

@danieljames

This comment has been minimized.

Show comment
Hide comment
@danieljames

danieljames May 30, 2017

Collaborator

There are a lot of other places where that would apply. I'll look into it, but I might just handle it directly.

Collaborator

danieljames commented May 30, 2017

There are a lot of other places where that would apply. I'll look into it, but I might just handle it directly.

@glenfe

This comment has been minimized.

Show comment
Hide comment
@glenfe

glenfe May 30, 2017

Member

Sounds good. I merged pointer_traits to master; you might want to also have Travis pull either develop or master versions of repositories instead (or in addition to) the latest Boost release archive.

Member

glenfe commented May 30, 2017

Sounds good. I merged pointer_traits to master; you might want to also have Travis pull either develop or master versions of repositories instead (or in addition to) the latest Boost release archive.

danieljames added a commit that referenced this pull request Jun 4, 2017

Stop dereferencing pointers to uninitialized memory
It's undefined behaviour. Still happens for piecewise construction
emultation for std::pair, I don't think there's anyway to avoid it.
I had considered using offsetof to get a pointer to a member, but that's
also undefined behaviour when a pair member doesn't have standard
layout. Piecewise construction emulation has other problems anyway.

So, this mostly fixes PR #5.

I also stopped using addressof in self-asssignment checks as operator&
is fine.

@glenfe glenfe closed this Jun 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment