Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Q_ASSERT(res == local) in QDateTime::currentDateTime() on ios
Forum Updated to NodeBB v4.3 + New Features

Q_ASSERT(res == local) in QDateTime::currentDateTime() on ios

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
12 Posts 4 Posters 852 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QOlzhas
    wrote on last edited by
    #1

    Hi there. I'm trying debug my ios app. I use QDateTime::currentDateTime() and get Q_ASSERT(res == local) which occur in QLocalTime func. I have no idea what's wrong, how can two pointers can be same?

    Axel SpoerlA 1 Reply Last reply
    0
    • Q QOlzhas

      Hi there. I'm trying debug my ios app. I use QDateTime::currentDateTime() and get Q_ASSERT(res == local) which occur in QLocalTime func. I have no idea what's wrong, how can two pointers can be same?

      Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #2

      @QOlzhas
      Can you pls post a stack trace?

      Software Engineer
      The Qt Company, Oslo

      Q 2 Replies Last reply
      0
      • Axel SpoerlA Axel Spoerl

        @QOlzhas
        Can you pls post a stack trace?

        Q Offline
        Q Offline
        QOlzhas
        wrote on last edited by
        #3

        @Axel-Spoerl, sure Screenshot_2024-03-04_at_09_46_55.png

        1 Reply Last reply
        0
        • Axel SpoerlA Axel Spoerl

          @QOlzhas
          Can you pls post a stack trace?

          Q Offline
          Q Offline
          QOlzhas
          wrote on last edited by
          #4

          @Axel-Spoerl. I'm a little confused, how can res and locale be the same thing? Are two pointers being compared that cannot be equal, because the addresses are always different, or do I not understand something? The contents of these two pointers are absolutely identical.

          Axel SpoerlA J.HilkJ 2 Replies Last reply
          0
          • Q QOlzhas

            @Axel-Spoerl. I'm a little confused, how can res and locale be the same thing? Are two pointers being compared that cannot be equal, because the addresses are always different, or do I not understand something? The contents of these two pointers are absolutely identical.

            Axel SpoerlA Offline
            Axel SpoerlA Offline
            Axel Spoerl
            Moderators
            wrote on last edited by
            #5

            @QOlzhas
            That's a bug. Can you file a bug report under https://bugreports.qt.io ?
            Thanks!

            Software Engineer
            The Qt Company, Oslo

            Q 1 Reply Last reply
            0
            • Q QOlzhas

              @Axel-Spoerl. I'm a little confused, how can res and locale be the same thing? Are two pointers being compared that cannot be equal, because the addresses are always different, or do I not understand something? The contents of these two pointers are absolutely identical.

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @QOlzhas out of curiosity, what do you have in line 58 of your main.cpp?


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              Q 1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @QOlzhas out of curiosity, what do you have in line 58 of your main.cpp?

                Q Offline
                Q Offline
                QOlzhas
                wrote on last edited by
                #7

                @J-Hilk, nothing criminal

                57 QApplication app (argc, argv);
                58 if (!AppManager::init (&app))
                59     return 0;
                

                AppManager is an application core class, which has logger:

                
                DapLogger::DapLogger(QObject *parent, QString appType, size_t prefix_width)
                    : QObject(parent)
                    , m_day(QDateTime::currentDateTime().toString("dd"))
                
                

                In the logger constructor calls QDateTime to get current time, where app assert on res == local.

                1 Reply Last reply
                0
                • Axel SpoerlA Axel Spoerl

                  @QOlzhas
                  That's a bug. Can you file a bug report under https://bugreports.qt.io ?
                  Thanks!

                  Q Offline
                  Q Offline
                  QOlzhas
                  wrote on last edited by
                  #8

                  @Axel-Spoerl, I did it. https://bugreports.qt.io/browse/QTBUG-122960

                  J.HilkJ 1 Reply Last reply
                  0
                  • Q QOlzhas

                    @Axel-Spoerl, I did it. https://bugreports.qt.io/browse/QTBUG-122960

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by J.Hilk
                    #9

                    @QOlzhas oh my, thats a rookie mistake in the Qt code,

                    it is

                    if(tm *res = localtime_r(&utc, local))
                    

                    but it should be

                    if(tm *res = localtime_r(&utc, local); res)
                    

                    someone disabled/ignored warnings during compiling ...


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    JonBJ 1 Reply Last reply
                    0
                    • J.HilkJ J.Hilk

                      @QOlzhas oh my, thats a rookie mistake in the Qt code,

                      it is

                      if(tm *res = localtime_r(&utc, local))
                      

                      but it should be

                      if(tm *res = localtime_r(&utc, local); res)
                      

                      someone disabled/ignored warnings during compiling ...

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #10

                      @J-Hilk said in Q_ASSERT(res == local) in QDateTime::currentDateTime() on ios:

                      if(tm *res = localtime_r(&utc, local); tm)

                      I don't use this kind of C++ construct, so excuse me if I am off base, but isn't tm a type here? Did you mean res by any chance?

                      And isn't the result of if(tm *res = localtime_r(&utc, local)) already res (even if it lacks an extra pair of of () to keep gcc happy, or test != nullptr if you prefer), unless this new-fangled inline declaration of a variable changes that behaviour?

                      J.HilkJ 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @J-Hilk said in Q_ASSERT(res == local) in QDateTime::currentDateTime() on ios:

                        if(tm *res = localtime_r(&utc, local); tm)

                        I don't use this kind of C++ construct, so excuse me if I am off base, but isn't tm a type here? Did you mean res by any chance?

                        And isn't the result of if(tm *res = localtime_r(&utc, local)) already res (even if it lacks an extra pair of of () to keep gcc happy, or test != nullptr if you prefer), unless this new-fangled inline declaration of a variable changes that behaviour?

                        J.HilkJ Offline
                        J.HilkJ Offline
                        J.Hilk
                        Moderators
                        wrote on last edited by
                        #11

                        @JonB said in Q_ASSERT(res == local) in QDateTime::currentDateTime() on ios:

                        I don't use this kind of C++ construct, so excuse me if I am off base, but isn't tm a type here? Did you mean res by any chance?

                        you're correct, I changed it.

                        the result is res, but its not checked. Well I think this may be compiler dependent.

                        I'm not sure anymore, you made me question myself T_T


                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                        Q: What's that?
                        A: It's blue light.
                        Q: What does it do?
                        A: It turns blue.

                        JonBJ 1 Reply Last reply
                        0
                        • J.HilkJ J.Hilk

                          @JonB said in Q_ASSERT(res == local) in QDateTime::currentDateTime() on ios:

                          I don't use this kind of C++ construct, so excuse me if I am off base, but isn't tm a type here? Did you mean res by any chance?

                          you're correct, I changed it.

                          the result is res, but its not checked. Well I think this may be compiler dependent.

                          I'm not sure anymore, you made me question myself T_T

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by JonB
                          #12

                          @J-Hilk said in Q_ASSERT(res == local) in QDateTime::currentDateTime() on ios:

                          the result is res, but its not checked. Well I think this may be compiler dependent.

                          I don't know what you mean by this. If you do an assignment in a conditional the result of the condition is the result of the assignment. That is C or C++. The only "wriggle" if that compilers like to warn you that if (a = b) might be a mistype for if (a == b), so they variously want you to either put in extra parentheses if ((a = b)) (gcc) or an explicit test if ((a = b) != nullptr) (MSVC?). Your new-fangled if (a = b; a) is just an alternative way of writing the same thing it seems to me?

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved