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
QtWS25 Last Chance

Qt for Android runs statements incorrectly

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 4 Posters 672 Views
  • 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.
  • LorenDBL Offline
    LorenDBL Offline
    LorenDB
    wrote on 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.

    KroMignonK 1 Reply Last reply
    0
    • LorenDBL LorenDB

      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.

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on 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)

      LorenDBL 1 Reply Last reply
      1
      • KroMignonK KroMignon

        @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?

        LorenDBL Offline
        LorenDBL Offline
        LorenDB
        wrote on 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
        • LorenDBL Offline
          LorenDBL Offline
          LorenDB
          wrote on last edited by
          #4

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

          JonBJ 1 Reply Last reply
          0
          • LorenDBL LorenDB

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

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on 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
            0
            • JonBJ JonB

              @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 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
              • LorenDBL Offline
                LorenDBL Offline
                LorenDB
                wrote on 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!

                JonBJ 1 Reply Last reply
                0
                • LorenDBL LorenDB

                  @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!

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on 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

                  • Login

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