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. Qt for Android runs statements incorrectly
Forum Updated to NodeBB v4.3 + New Features

Qt for Android runs statements incorrectly

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 4 Posters 718 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.
  • L Offline
    L Offline
    LorenDB
    wrote on 28 Jan 2021, 02:47 last edited by
    #1

    My app runs normally on my Linux laptop, but when I run it on an Android phone, it fails to correctly calculate some data if it is not a debug build.

    I have a hunch that it may be due to optimization; however, I haven't been able to debug a "Release with debug info" build since my debugger won't connect to the phone.

    K 1 Reply Last reply 28 Jan 2021, 09:11
    0
    • L LorenDB
      28 Jan 2021, 02:47

      My app runs normally on my Linux laptop, but when I run it on an Android phone, it fails to correctly calculate some data if it is not a debug build.

      I have a hunch that it may be due to optimization; however, I haven't been able to debug a "Release with debug info" build since my debugger won't connect to the phone.

      K Offline
      K Offline
      KroMignon
      wrote on 28 Jan 2021, 09:11 last edited by
      #2

      @LorenDB What kind of help do you expect without given at least a way to reproduce this nor giving with Qt version you have used?

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      L 1 Reply Last reply 28 Jan 2021, 12:08
      1
      • K KroMignon
        28 Jan 2021, 09:11

        @LorenDB What kind of help do you expect without given at least a way to reproduce this nor giving with Qt version you have used?

        L Offline
        L Offline
        LorenDB
        wrote on 28 Jan 2021, 12:08 last edited by
        #3

        @KroMignon oops, sorry! 😳 I was ready to sleep and trying to get something posted quickly, so I guess I forgot about that.

        My Qt version is 5.15.1. I'll try to get the code on GitHub and link back here post-haste.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          LorenDB
          wrote on 28 Jan 2021, 22:27 last edited by
          #4

          My code is available at https://github.com/LorenDB/QCalc

          J 1 Reply Last reply 29 Jan 2021, 08:16
          0
          • L LorenDB
            28 Jan 2021, 22:27

            My code is available at https://github.com/LorenDB/QCalc

            J Offline
            J Offline
            JonB
            wrote on 29 Jan 2021, 08:16 last edited by
            #5

            @LorenDB
            That is large code, with no indication as to what goes wrong when. Don't know what help you expect with that. It is your job to cut that down to some minimal example which shows the issue.

            It is possible your code illustrates a bug in the compiler's optimizer. However, it is also possible that there is a bug in your code, which only shows up in Release, not Debug, build. If I were a betting man....

            M 1 Reply Last reply 29 Jan 2021, 11:45
            0
            • J JonB
              29 Jan 2021, 08:16

              @LorenDB
              That is large code, with no indication as to what goes wrong when. Don't know what help you expect with that. It is your job to cut that down to some minimal example which shows the issue.

              It is possible your code illustrates a bug in the compiler's optimizer. However, it is also possible that there is a bug in your code, which only shows up in Release, not Debug, build. If I were a betting man....

              M Offline
              M Offline
              mvuori
              wrote on 29 Jan 2021, 11:45 last edited by
              #6

              Indeed. Uninitialized variables are one common reason for this kind of things, and the code has at least one occurence of such.

              1 Reply Last reply
              1
              • L Offline
                L Offline
                LorenDB
                wrote on 29 Jan 2021, 21:09 last edited by
                #7

                @JonB I apologize, I should know better than to just post code and expect people to know what I mean. I'll try to do better in the future.

                @mvuori, @JonB: it turns out that my problem was an uninitialized variable.

                For the record:

                My problem was that when I entered some data into the data input and clicked the button (or pressed Enter), certain statistics such as the sum of the squares would not calculate correctly. It appeared that the mean was being calculated as zero (even though it wasn't). Initializing the accumulator in the calculateMean() function solved the problem. Thanks for the tip!

                J 1 Reply Last reply 29 Jan 2021, 21:21
                0
                • L LorenDB
                  29 Jan 2021, 21:09

                  @JonB I apologize, I should know better than to just post code and expect people to know what I mean. I'll try to do better in the future.

                  @mvuori, @JonB: it turns out that my problem was an uninitialized variable.

                  For the record:

                  My problem was that when I entered some data into the data input and clicked the button (or pressed Enter), certain statistics such as the sum of the squares would not calculate correctly. It appeared that the mean was being calculated as zero (even though it wasn't). Initializing the accumulator in the calculateMean() function solved the problem. Thanks for the tip!

                  J Offline
                  J Offline
                  JonB
                  wrote on 29 Jan 2021, 21:21 last edited by
                  #8

                  @LorenDB
                  In practice, uninitialized variables can often have a different value in Debug vs Release builds, and be the cause of misbehaviour in one versus the other. They can be difficult to track down. I believe there are specialized tools to analyze code or do runtime detection for them, don't know if there is anything FOSS.

                  1 Reply Last reply
                  0

                  3/8

                  28 Jan 2021, 12:08

                  topic:navigator.unread, 5
                  • Login

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