[Development] What's the status of a moved-from object?
kshegunov at gmail.com
Mon May 20 22:58:49 CEST 2019
On Mon, May 20, 2019 at 10:07 PM Allan Sandfeld Jensen <kde at carewolf.com>
> On Montag, 20. Mai 2019 20:18:32 CEST Mutz, Marc via Development wrote:
> > Where we still, maybe, disagree, is whether d == nullptr is a valid
> > state. The difference is whether member functions other then destruction
> > and assignment check for a nullptr d. I'd propose that on classes under
> > the above premiss, Q_D contains Q_ASSERT(d). This, I think, strikes the
> > best balance between safety and speed.
> I agree. I would consider anything other than deleting or reassigning a
> object undefined behavior, so asserting on it seems like a good help to
> of our APIs.
I agree as well, although I have a minor nitpick. Q_ASSERT works only if it
was not stripped while building Qt. Meaning that I'm often working, as I'm
sure other users, on Linux especially, with the default (i.e. release)
version of Qt from the repo. Granted it may be my own fault, but in this
case the assert isn't tripped and this code simply segfaults for reasons
that aren't so obvious. Any suggestions how to mitigate that? Somehow
*suggest* to the user that [s]he's supposed to build in debug mode
otherwise they're on their own?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Development