Uh oh!
There was an error while loading. Please reload this page.
Fix assertion failure for unions (#1685) - #1709
Merged
Merged
Conversation
rolandd
commented
Feb 24, 2019
ContributorAuthor
None of the automated test failures look related to my change. Most of the Travis CI tests passed, and the environments that failed seem like flakiness unrelated to my change; the AppVeyor build failures look like a configuration problem too. |
wjakob
commented
Jun 10, 2019
Member
Hi @rolandd, apologies for the long delay-- could you rebase your commits to the latest pybind11 so that CI has a chance to re-run? Thanks, |
rolandd
commented
Jun 10, 2019
ContributorAuthor
Done, just rebased on pybind11 master. |
rolandd
commented
Jun 10, 2019
ContributorAuthor
The travis style check failed with but my change doesn't touch that file. |
In def_readonly and def_readwrite, there is an assertion that the member comes from the class or a base class: static_assert(std::is_base_of<C, type>::value, "..."); However, if C and type are the same type, is_base_of will still only be true if they are the same _non-union_ type. This means we can't define accessors for the members of a union type because of this assertion. Update the assertion to test std::is_same<C, type>::value || std::is_base_of<C, type>::value which will allow union types, or members of base classes. Also add a basic unit test for accessing unions.
wjakob
commented
Jun 11, 2019
Member
Fantastic, thank you! |
wjakob pushed a commit
that referenced
this pull request
Jun 11, 2019
In def_readonly and def_readwrite, there is an assertion that the member comes from the class or a base class: static_assert(std::is_base_of<C, type>::value, "..."); However, if C and type are the same type, is_base_of will still only be true if they are the same _non-union_ type. This means we can't define accessors for the members of a union type because of this assertion. Update the assertion to test std::is_same<C, type>::value || std::is_base_of<C, type>::value which will allow union types, or members of base classes. Also add a basic unit test for accessing unions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In def_readonly and def_readwrite, there is an assertion that the member comes
from the class or a base class:
However, if C and type are the same type, is_base_of will still only be true
if they are the same non-union type. This means we can't define accessors
for the members of a union type because of this assertion.
Update the assertion to test
which will allow union types, or members of base classes.
Also add a basic unit test for accessing unions.