Qt for Android runs statements incorrectly
-
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.
-
My code is available at https://github.com/LorenDB/QCalc
-
@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....
-
@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! -
@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.