[Interest] QDateTime::toString() fails when used in exit handler

Bernhard Lindner private at bernhard-lindner.de
Fri Jun 19 22:12:17 CEST 2020


Hi!

I tried to log `std::exit` calls in my GCC10 compiled Qt 5.14.2 application under KDE Neon
18.04. This fails when turning a `QDateTime` object into a string. It can be reproduced
with the following snippet:

    void exitHandler() noexcept
    {
       QString b = QDateTime::currentDateTime().toString();
    }
    
    int main(int pArgc, char* pArgv[]) noexcept
    {
       std::atexit(&exitHandler);
       QString a = QDateTime::currentDateTime().toString();
       std::exit(1);
    
       return 0;
    }

Variable `a` contains the expected date/time while variable `b` is empty. When using UTC
time, `b` is " GMT". I am not aware of any related restrictions of exit-handlers.

Can someone tell me what is going wrong here?

-- 
Best Regards,
Bernhard Lindner



More information about the Interest mailing list