[Development] QDateTime addDays logic

Sérgio Martins sergio.martins at kdab.com
Thu Dec 13 15:16:08 CET 2018


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



More information about the Development mailing list