Stop requiring an out of class definition for version traits - #370
Open
gennaroprota wants to merge 1 commit into
Open
Stop requiring an out of class definition for version traits#370gennaroprota wants to merge 1 commit into
gennaroprota wants to merge 1 commit into
Conversation
`version_type` took its argument by reference, so constructing one from `version<T>::value` could bound a reference to that static data member and ODR-used it. A trait written by hand with no out-of-class definition for the data member, then left an undefined reference behind on compilers which do not fold the constant away. Spelling the value as an `int` happened to work only because the conversion to `unsigned int` created a temporary for the reference to bind to. Taking the argument by value removes the ODR-use, so both `int` and `unsigned int` work. The specializations `BOOST_CLASS_VERSION` writes have no definition either, and were relying on the same accident. `object_id_type` had the same constructor and is changed along with it. Fixes #311.
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 free
to 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.
version_typetook its argument by reference, so constructing one fromversion<T>::valuecould bound a reference to that static data member and ODR-used it. A trait written by hand with no out-of-class definition for the data member, then left an undefined reference behind on compilers which do not fold the constant away. Spelling the value as aninthappened to work only because the conversion tounsigned intcreated a temporary for the reference to bind to.Taking the argument by value removes the ODR-use, so both
intandunsigned intwork. The specializationsBOOST_CLASS_VERSIONwrites have no definition either, and were relying on the same accident.object_id_typehad the same constructor and is changed along with it.Fixes #311.