[Development] QDateTime addDays logic

NIkolai Marchenko enmarantispam at gmail.com
Thu Dec 13 15:24:24 CET 2018


It's not like I don't understand all that. But I am not that person who
introduced the regression and

a) He doesn't use a compiler that supports this warning
b) ... and he wouldn't have read it in the first place. (unfortunately)
c) He doesn't much care about docs

Not saying it's correct, just stating the fact that function name is
confusing and potentially problematic because it doesn't do what it states
it does.

On Thu, Dec 13, 2018 at 5:16 PM Sérgio Martins <sergio.martins at kdab.com>
wrote:

> On 2018-12-13 13:48, NIkolai Marchenko wrote:
> > This non obvious (from function name) behaviour actually caused
> > infinite
> > loop regression in our code just recently.
> > The person used it inside a while loop thinking it will loop upwards
> > and
> > stop.
>
>
> If your compiler supports it, you should get a warning such as:
>
> warning: ignoring return value of ‘QDateTime QDateTime::addDays(qint64)
> const’, declared with attribute nodiscard [-Wunused-result]
>
> Also useful for many other Qt classes.
>
>
> Regards,
> --
> Sérgio Martins | sergio.martins at kdab.com | Senior Software Engineer
> Klarälvdalens Datakonsult AB, a KDAB Group company
> Tel: Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
> KDAB - The Qt, C++ and OpenGL Experts
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20181213/af391bd2/attachment.html>


More information about the Development mailing list