Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Qt for Android runs statements incorrectly

    Mobile and Embedded
    4
    8
    296
    Loading More Posts
    • 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.
    • LorenDB
      LorenDB last edited by

      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.

      KroMignon 1 Reply Last reply Reply Quote 0
      • KroMignon
        KroMignon @LorenDB last edited by

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

        LorenDB 1 Reply Last reply Reply Quote 1
        • LorenDB
          LorenDB @KroMignon last edited by

          @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 Reply Quote 0
          • LorenDB
            LorenDB last edited by

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

            JonB 1 Reply Last reply Reply Quote 0
            • JonB
              JonB @LorenDB last edited by

              @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 Reply Quote 0
              • M
                mvuori @JonB last edited by

                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 Reply Quote 1
                • LorenDB
                  LorenDB last edited by

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

                  JonB 1 Reply Last reply Reply Quote 0
                  • JonB
                    JonB @LorenDB last edited by

                    @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 Reply Quote 0
                    • First post
                      Last post