-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Deprecate object::borrowed
/object::stolen
#771
Conversation
(Awaiting confirmation from #770 that this actually fixes it). |
One comment: In C++17 this could be fixed by adding just: inline constexpr object::borrowed_t object::borrowed;
inline constexpr object::stolen_t object::stolen; which is, of course, much nicer than the template hack, but seeing as we need the hack for 14/11 already, I don't see much advantage in using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks too heavyweight. I would just replace all usages of borrowed
with borrowed_t{}
. The borrowed
definition itself might need to stay for backward compatibility (to be removed in v3.0 with other breaking changes).
I'm fine with that. Do you mean heavyweight in terms of added compiler complexity, or something else? (I did check that this doesn't change |
I mean complex both for the compiler and for humans. The only advantage is avoiding |
The constexpr static instances can cause linking failures if the compiler doesn't optimize away the reference, as reported in pybind#770. There's no particularly nice way of fixing this in C++11/14: we can't inline definitions to match the declaration aren't permitted for non-templated static variables (C++17 *does* allows "inline" on variables, but that obviously doesn't help us.) One solution that could work around it is to add an extra inherited subclass to `object`'s hierarchy, but that's a bit of a messy solution and was decided against in pybind#771 in favour of just deprecating (and eventually dropping) the constexpr statics. Fixes pybind#770.
c1c5586
to
4a29ba8
Compare
object::borrowed
/object::stolen
object::borrowed
/object::stolen
object::borrowed
/object::stolen
Okay; updated the PR to deprecate |
Looks good to me. |
Looks good -- merged! |
PR #771 deprecated them as they can cause linking failures (#770), but the deprecation tags cause warnings on GCC 5.x through 6.2.x. Removing them entirely will break backwards-compatibility consequences, but the effects should be minimal (only code that was inheriting from `object` could get at them at all as they are protected). Fixes #777
Provides (via a dummy template parameter hack) inline definitions of object::borrowed/object::stolen.The constexpr static instances can cause linking failures if the compiler doesn't optimize away the reference, as reported in #770.
There's no particularly nice way of fixing this in C++11/14: we can't inline definitions to match the declaration aren't permitted for non-templated static variables (C++17 does allows "inline" on variables, but that obviously doesn't help us.)
One solution that could work around it is to add an extra inherited subclass to
object
's hierarchy, but that's a bit of a messy solution and was decided against in #771 in favour of just deprecating (and eventually dropping) the constexpr statics.Fixes #770.