[Development] What's the status of a moved-from object?

Konstantin Ritt ritt.ks at gmail.com
Sat May 25 17:24:13 CEST 2019


сб, 25 мая 2019 г., 12:30 Mutz, Marc via Development <
development at qt-project.org>:

> Further to the question about default ctors for such "obvious" stuff as
>
> On 2019-05-21 10:27, Mutz, Marc via Development wrote:
> >     class QRect {
> >        int x, y, w, h;
> >     public:
> >        QRect() = default;
> >     };
> >     QRect r; // partially-formed
> >     r.x();   // compilers _already_ warn about this
> >     QRect r = {}; // zero-initialized
>
> I've been working with Qt for two decades now. Guess what I just wrote
> and had to debug?
>
>     QSize zero;
>
> Anyone spot the bug? Hint: the following /is/ correct:
>
>     QPoint origin;
>
> Now, anyone here who wants to defend that as good API design?
>
> Anyone?
>
> Repeat after me: default ctors do _not_ establish a valid value.
>

Perhaps you mean "trivial type's default ctors do _not_ establish a valid
value"?

Konstantin

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20190525/fc130112/attachment.html>


More information about the Development mailing list