Itay Grudev
Itay Grudev

Reputation: 7454

Different (null) result upon compilation

I have a C++ (Qt) project with a statically linked (Non Qt, written by me) library, which does some computation and a GUI application based on that library.

Half of the times when I compile the GUI application (which has the computation library statically linked) I receive null results.

If I clean and rebuild the entire project it works again.

I have absolutely no idea where this glitch comes from and I was looking for an explanation or at least guidance what and where to be looking for.

A bit more on how the library works:
An instance of a Parameters class is initiated and then passed as a pointer to the constructor of a Computation class. It then has a method that does the computation itself based on the parameters contained in the Parameters and returns a long double result.

Thanks!

Upvotes: 0

Views: 56

Answers (1)

6EQUJ5
6EQUJ5

Reputation: 3302

If you have what appears to be intermittent memory corruption, run your program using valgrind, which is available in most major Linux distributions.

For example:

valgrind ./my_binary

This will produce a (potentially) large log of memory leaks, overruns, uninitalised variables or other invalid memory accesses, and importantly with line numbers and stack traces with the right options. including uninitialised variables as suggested by @MichaelWalz in the comments.

This may let you narrow down the problem is in your code or the library.

Upvotes: 2

Related Questions